2011-01-20 31 views
0
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 Visual Studio 2005中的錯誤是參數 古村是一個列,幷包含Unicode數據 當編譯以下錯誤erised 「這些列不」目前有獨特的價值」使用Unicode

如何搜索Unicode數據從數據集 如何糾正上述C

回答

0

看起來這行

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

是一個錯誤「這些列不'目前有獨特的價值」,因爲您的數據與主鍵上的獨特要求運行衝突。

這意味着您不能使用Find。這與SQL Server或Unicode數據無關。

改爲擺脫這條線myDSGN.Tables("Villages").PrimaryKey = myPrimaryKey並使用.Select代替