Problem with DataReader.Update, CommandBuilder
-
vendredi 16 septembre 2005 13:12It doesn't ******** work!!
here's the code, taken from...ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref/html/T_System_Data_SqlClient_SqlCommandBuilder.htm
Dim myConn As New SqlCeConnection("Data Source = " & "\Storage\MASDB.SDF")
Dim myDataAdapter As New SqlCeDataAdapter()
Dim strSQL as String = "SELECT Text FROM Test where ID = 1"
myDataAdapter.SelectCommand = New SqlCeCommand(strSQL, myConn)
Dim cb As SqlCeCommandBuilder = New SqlCeCommandBuilder(myDataAdapter)
myConn.Open()
Dim myDS As DataSet = New DataSet
myDataAdapter.Fill(myDS)
myDS.Tables(0).Rows(0).Item(0) = "Bye World"
Try
myDataAdapter.Update(myDS)
Catch ex As Exception
MsgBox("tfswp!")
End Try
myConn.Close()
The CommandBuilder doesn't seem to be doing what the documentation says it does, i.e. create Update/Insert/Delete commands for the DataAdaptor.
Am I doing something stupid or has Microsoft just wasted a day of my life?
Toutes les réponses
-
vendredi 16 septembre 2005 16:21
Is ID a primary key column on your TEST table? Also, what is the exception being thrown? Change your catch statement to:
Catch ex As Exception
MsgBox(ex.Message)
and send us the resulting message so we can better help.
Josh -
lundi 19 septembre 2005 12:42ID wasn't a primary key, but is now, so it all works :-)

