I"m trying to update the database from my datasetusing this code:
Dim oConnection As New SqlConnection("Server=localhost;DataBase=cartisiyot;Integrated Security=SSPI")
oConnection.Open()
Dim cmd As New SqlCommand()
Dim strsql As String
strsql = "SELECT * FROM main WHERE musag = " & musag.Text & ""
cmd.Connection = oConnection
cmd.CommandText = strsql
Dim datareader As SqlDataAdapter
datareader = New SqlDataAdapter(cmd)
datareader.Fill(myDS)
msg.Visible = False
updat.Visible = False
cance.Visible = False
updatenow.Visible = False
myDS.Tables(0).Rows(0).Item(1) = musag.Text
myDS.Tables(0).Rows(0).Item(2) = declaretion.Text
myDS.Tables(0).Rows(0).Item(3) = sources.Text
myDS.Tables(0).Rows(0).Item(4) = moresources.Text
myDS.Tables(0).Rows(0).Item(5) = comments.Text
myDS.Tables(0).Rows(0).Item(6) = autor.Text
datareader.Update(myDS)
oConnection.Close()
myDS.Dispose()
and i"m geting the same error massege again and again:
"Update requires a valid UpdateCommand when passed DataRow collection with modified rows."
I think i miss understood something about updating using datasets.
can any body help?
Dim oConnection As New SqlConnection("Server=localhost;DataBase=cartisiyot;Integrated Security=SSPI")
oConnection.Open()
Dim cmd As New SqlCommand()
Dim strsql As String
strsql = "SELECT * FROM main WHERE musag = " & musag.Text & ""
cmd.Connection = oConnection
cmd.CommandText = strsql
Dim datareader As SqlDataAdapter
datareader = New SqlDataAdapter(cmd)
datareader.Fill(myDS)
msg.Visible = False
updat.Visible = False
cance.Visible = False
updatenow.Visible = False
myDS.Tables(0).Rows(0).Item(1) = musag.Text
myDS.Tables(0).Rows(0).Item(2) = declaretion.Text
myDS.Tables(0).Rows(0).Item(3) = sources.Text
myDS.Tables(0).Rows(0).Item(4) = moresources.Text
myDS.Tables(0).Rows(0).Item(5) = comments.Text
myDS.Tables(0).Rows(0).Item(6) = autor.Text
datareader.Update(myDS)
oConnection.Close()
myDS.Dispose()
and i"m geting the same error massege again and again:
"Update requires a valid UpdateCommand when passed DataRow collection with modified rows."
I think i miss understood something about updating using datasets.
can any body help?