简体   繁体   English

Unicode的Visual Studio 2005错误

[英]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" pGNe是参数VillageSin是列并且包含UNICODE数据在编译时出现以下错误提示“这些列当前不具有唯一值”

How can search unicode data from Dataset How to correct above c 如何从数据集中搜索unicode数据如何在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 . 这意味着您不能使用Find This has nothing to do with SQL Server or Unicode data. 这与SQL Server或Unicode数据无关。

instead get rid of this line myDSGN.Tables("Villages").PrimaryKey = myPrimaryKey and use .Select instead 而是摆脱myDSGN.Tables("Villages").PrimaryKey = myPrimaryKey这一行myDSGN.Tables("Villages").PrimaryKey = myPrimaryKey并使用.Select代替

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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