简体   繁体   中英

Visual Studio 2005 error with Unicode

    Dim findTheseVals(1) As Object
    ' Set the values of the keys to find.
    Dim myDAgn As New SqlDataAdapter

    findTheseVals(0) = pDivisionno
    findTheseVals(1) = pGNe

    sqlCon.Open()

    Dim myDSGN As New DataSet
    myDAgn.SelectCommand = New SqlCommand("SELECT * FROM Villages", sqlCon)
    myDAgn.Fill(myDSGN, "Villages")

    myPrimaryKey(0) = myDSGN.Tables("Villages").Columns("DivisionNo")
    myPrimaryKey(1) = myDSGN.Tables("Villages").Columns("VillageSin")

    myDSGN.Tables("Villages").PrimaryKey = myPrimaryKey

    Dim myRow As DataRow

    myRow = myDSGN.Tables("Villages").Rows.Find(findTheseVals)


    If Not (myRow Is Nothing) Then
        isExistsVi = True
        VIid = myRow.Item("VillageID")
    Else
        isExistsVi = False
    End If
    sqlCon.Close()

pGNe is Parameter VillageSin is a Column and contain UNICODE Data When compile following error erised "These Columns dont' Currently have unique values"

How can search unicode data from Dataset How to correct above c

It seems like this line

myDSGN.Tables("Villages").PrimaryKey = myPrimaryKey

is the one with the error "These Columns dont' Currently have unique values" because your data is running afoul of the unique requirement on primary keys.

All this means is that you can't use Find . This has nothing to do with SQL Server or Unicode data.

instead get rid of this line myDSGN.Tables("Villages").PrimaryKey = myPrimaryKey and use .Select instead

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM