Hi All!
I want to update a record in my database but without using "update mytblname" query.
I am using following code
sql = "select * from customer where id = " & Val(Me.id.Text)
Dim adapter As New SqlDataAdapter(sql, conn)
Dim builder As SqlCommandBuilder = New SqlCommandBuilder(adapter)
Dim ds1 As New DataSet("customer")
adapter.Fill(ds1, "customer")
Dim T As DataTable = ds1.Tables("customer")
Dim i As Integer
Dim row As DataRow
If T.Rows.Count = 0 Then
row = T.NewRow
Else
T.Rows(0).BeginEdit()
row = T.Rows(0)
row.BeginEdit()
End If
row("cname") = cname.Text
If addre.Text = "" Then addre.Text = "-"
row("address") = Me.addre.Text
If email.Text = "" Then email.Text = "-"
row("email") = email.Text
If ph.Text <> "" Then row("ph") = ph.Text
If cont.Text <> "" Then row("cont") = cont.Text
If other.Text <> "" Then row("other") = other.Text
If desi.Text <> "" Then row("desi") = desi.Text
row("zone") = Me.cmbzone.Text
If Val(Me.id.Text) = 0 Then
T.Rows.Add(row)
' Else
Else
T.Rows(0).EndEdit()
row.EndEdit()
End If
adapter.Update(ds1, "customer")
adapter.Dispose()
Its not updating to database.
What is problem in above code ?