Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to edit,delete and save for the sql query. i already have the codes for adding of query...i have some problems in edit,delete and save..

here is my code for adding :

Dim Conn As New SqlConnection(conectdb.tblconnect) 
        Dim Cmd As New SqlCommand
        Dim ra As Integer
        Dim qry = "INSERT INTO table1 (fname,lname,age) VALUES ('" & txt1.Text & "','" & txt2.Text & "','" & txt3.Text & "')"
        Conn.Open()
        Cmd = New SqlCommand(qry, Conn)
        ra = Cmd.ExecuteNonQuery()
        MessageBox.Show("Success")
        Conn.Close()
Posted
Updated 10-Feb-11 16:17pm
v2

There are quite a few issues in your code snippet. You should go through these articles on MSDN, most of them will have samples in VB:

http://msdn.microsoft.com/en-us/library/ms171886(v=VS.100).aspx[^]

And this:

http://msdn.microsoft.com/en-us/library/h0y4a0f6.aspx[^]
 
Share this answer
 
v2
try this code for update sql table


SQL
cmd = New SqlCommand("update std set name=" & "'" & TextBox2.Text & "'" & "," &  "," & "Age=" & TextBox3.Text & "where id=" & TextBox1.Text & "", cn)
        cmd.ExecuteNonQuery()
        adp.Fill(ds, "tabel name")
        MsgBox("Record Updated.....")


for delete

VB
cmd = New SqlCommand("Delete from tablename where id=" & TextBox1.Text & " ", cn)
        cmd.ExecuteNonQuery()
        adp.Fill(ds, "table name")
        MsgBox("Record Deleted....")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900