achal kumar

achal kumar

  • NA
  • 1
  • 0

problem with update using data set

Feb 1 2006 9:23 AM
i am getting problem while i am trying to update all the fields of a table with dataset using
disconnected dataset and dataadapter. my table contains 3 fields of eid,name,sal my program able to update 2 fields but when i want to update eid the error null error exception is coming
my code is

Dim con As New SqlConnection("workstation id=SHYPN220;packet size=4096;user id=sa;initial catalog=pubs;persist security info=True")

Dim da As New SqlDataAdapter("select * from emp", con)

Dim cb As SqlCommandBuilder

Dim ds As New DataSet

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim r As DataRow

con.Open()

da.MissingSchemaAction = MissingSchemaAction.AddWithKey

da.Fill(ds, "emp")

cb = New SqlCommandBuilder(da)

Dim x As Integer = Val(t1.Text)

r = ds.Tables("emp").Rows.Find(x)

r.Item(0) = Val(t1.Text)----------> here i am getting error

r.Item(1) = t2.Text

r.Item(2) = Val(t3.Text)

da.Update(ds, "emp")

MsgBox("record updated")

con.Close()

 

 

End Sub

so please give the solution urgently