none
Primary Key Value Problem RRS feed

  • Question

  • In Oracle I find duplicate value in primary key. Well, not that same. One is single byte data and other is double byte data. For example

     

    row 1:  xyz

    row 2 : xyz

     

    Here 2nd xyz is a double byte data, that I can write by a Japanese key board. So, these 2 same (as they look) value can be in a primary column (at least in oracle).

     

    But, Microsoft Access does not support that. I can not try it in MS SQL Server yet.

     

    Now, my problem is, I need the get these data by ADO.Net, save the result in XML data and again load the XML data in a table with the table schema. But It's giving me primary key violation error.

     

    It would be great if anybody can help me finding a solution for that

     

    Thank you.

     

     

    Monday, August 27, 2007 4:13 AM

All replies

  • One observation. When I read the data into a DataTabel, the duplicate (not duplicate data actually) row(s) skipped when I apply the Table Schema before loading from Oracle database.

    Monday, August 27, 2007 6:15 AM

  • Hi nazmul
    >>   In Oracle I find duplicate value in primary key.
       No way when primary key defined on a column there is no ? of repeated value. In case of composite primary key. Repeated values may occur, repeated combinations are not possible. Ok
    xyz != x y z ok Here is an example. U can try it on sqlserver or in oracle

    This is in sqlserver.
    create table u(i smallint ,st  varchar(10) primary key)
    insert into u values(1,'xyz')
    go
    insert into u values(2,'x y z')
    select * from u

    In asp.net
    dim cn as sqlconnection
    cn=new sqlconnection

    cn.ConnectionString = "data source=localhost;initial catalog=sridb;persist security info=False;
    user id=sa;password=;packet size=4096"
            Dim ad As SqlDataAdapter
            ad = New SqlDataAdapter

            ad.SelectCommand = New SqlCommand("select * from u", cn)
            ds = New DataSet
            ad.Fill(ds)
            dbgrid_donations.DataSource = ds
            dbgrid_donations.DataBind()
            ds.WriteXml("d:\u.xml", XmlWriteMode.WriteSchema)

    Thanks

    Baba
    Monday, August 27, 2007 11:00 AM
  • >>No way when primary key defined on a column there is no ? of repeated value. ....

    It was fun (from my frustration...)...in the first line Smile  ofcourse there were/are/will be no question.

     

    Anyway.

     

     

    >>This is in sqlserver.
    >>create table u(i smallint ,st  varchar(10) primary key)
    >>insert into u values(1,'xyz')
    >>go
    >>insert into u values(2,'x y z')
    >>select * from u

     

    I see you place a space between x and y , y and z in the second insert....am I right? If so, the actual scenerio is that, there is no space....they are double byte charcter...in my case..

     

    for example unicode value of single byte x is 0078 whereas unicode value of double byte x is FF58. In that way, if you write a double byt xyz it may (depend on font) look that there is a space between them....but no space between 2 charcter.

     

    Now I would like to request you to make a second insert.

     

    Thank you.

    Tuesday, August 28, 2007 3:50 AM
  • I got the solution:

     

    DataTable.CaseSensitive = true;

     

    Regards

    Wednesday, August 29, 2007 6:42 AM