Question Update to database

shukla

New member
Joined
Dec 9, 2008
Messages
4
Programming Experience
3-5
:confused:
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 ?
 
Read the DNU link in my signature
Also read the DW1 links

But consider upgrading your Visual studio to something more modern, and follow the DW2 linked tutorials instead
 
Well, if the people who wrote the language youre using (Microsoft) cannot help you, I don't think i'll be able to

Do yourself a favour, download the latest VB Express, and follow the modern tutorials
 

Latest posts

Back
Top