编辑删除保存更新sql 2005 [英] edit delete save update sql 2005
本文介绍了编辑删除保存更新sql 2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何编辑,删除和保存sql查询.我已经有添加查询的代码...我在编辑,删除和保存时遇到了一些问题.
这是我添加的代码:
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()
推荐答案
您的代码段中有很多问题.您应该在MSDN上阅读以下文章,其中大多数将在VB中提供示例:
http://msdn.microsoft.com/en-us/library/ms171886 (v = VS.100).aspx [ http://msdn.microsoft.com/en-us/library/h0y4a0f6.aspx [ ^ ]
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[^]
尝试使用此代码更新sql表
try this code for update sql table
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
cmd = New SqlCommand("Delete from tablename where id=" & TextBox1.Text & " ", cn)
cmd.ExecuteNonQuery()
adp.Fill(ds, "table name")
MsgBox("Record Deleted....")
这篇关于编辑删除保存更新sql 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文