Hi TT
I have read all about commandbuilder in several NG's but still I can't find out whats wrong
I have a SQL database called "m100SQL" with a table called "m100", below is the code I use to fill a dataset, and update the database, but it fails. Could somebody please tell me what I'm doing wrong
\Bo
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
Dim con As New SqlConnection
Dim PubConn As New SqlConnection("Data Source=(local);Initial Catalog=m100SQL;Integrated Security=SSPI;"
Dim pubCom As New SqlCommand("select * from m100", PubConn)
Dim daPub As New SqlDataAdapter
Dim byg As New SqlCommandBuilder
Dim ds As New DataSet
'*** dataset fill
PubConn.Open() 'open´a dataconnection to the database
daPub.SelectCommand = pubCom
daPub.AcceptChangesDuringFill = False
daPub.Fill(ds, "m100"
PubConn.Close()
ds.AcceptChanges()
ds.Tables("m100"
.Rows(0)(0) = 50 ' edit the dataset
PubConn.Open()
byg = New SqlCommandBuilder(daPub)
daPub.InsertCommand = byg.GetInsertCommand
daPub.InsertCommand.Connection = PubConn
daPub.UpdateCommand = byg.GetUpdateCommand
daPub.UpdateCommand.Connection = PubConn
daPub.Update(ds, "m100"
'*******FAILS HERE WITH SYSTEM ERROR
PubConn.Close()
End Sub
I have read all about commandbuilder in several NG's but still I can't find out whats wrong
I have a SQL database called "m100SQL" with a table called "m100", below is the code I use to fill a dataset, and update the database, but it fails. Could somebody please tell me what I'm doing wrong
\Bo
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
Dim con As New SqlConnection
Dim PubConn As New SqlConnection("Data Source=(local);Initial Catalog=m100SQL;Integrated Security=SSPI;"
Dim pubCom As New SqlCommand("select * from m100", PubConn)
Dim daPub As New SqlDataAdapter
Dim byg As New SqlCommandBuilder
Dim ds As New DataSet
'*** dataset fill
PubConn.Open() 'open´a dataconnection to the database
daPub.SelectCommand = pubCom
daPub.AcceptChangesDuringFill = False
daPub.Fill(ds, "m100"
PubConn.Close()
ds.AcceptChanges()
ds.Tables("m100"
PubConn.Open()
byg = New SqlCommandBuilder(daPub)
daPub.InsertCommand = byg.GetInsertCommand
daPub.InsertCommand.Connection = PubConn
daPub.UpdateCommand = byg.GetUpdateCommand
daPub.UpdateCommand.Connection = PubConn
daPub.Update(ds, "m100"
PubConn.Close()
End Sub