' 建立连接
dim delstring as string
delstring = textbox4.text
dim delsel as string
delsel = "select * from users where nameid='" & delstring & "'"
'创建查询字符串
oledbcommand1 = new oledbcommand
me.oledbcommand1.commandtext = delsel
me.oledbcommand1.connection = oledbconnection1
try
dim selreader as oledbdatareader = oledbcommand1.executereader()
if not selreader.read then
'假如读不到,就表明数据库无此数据,无法进行删除操作
messagebox.show("数据库中无该记录!")
else
selreader.close()
'要对数据进行操作,必须首把datareader关掉
dim delrecord as string
delrecord = "delete * from users where nameid='" & delstring & "'"
'建立删除字符串sql语句,以上都是
oledbcommand1 = new oledbcommand
me.oledbcommand1.commandtext = delrecord
me.oledbcommand1.connection = oledbconnection1
me.oledbcommand1.executenonquery()
messagebox.show("删除成功!!")
'再把进行删除操作的数据库,再次把数据库中数据保存成XML文档
dataset1 = new dataset
oledbdataadapter1 = new oledbdataadapter("select * from users", oledbconnection1)
oledbdataadapter1.fill(dataset1, "users")
dataset1.writexml("myxml.xml")
end if
catch ex as exception
messagebox.show(ex.message)
finally
oledbconnection1.close()
end try
else
messagebox.show("请输入你想删除的记录!")
end if
//======================= 重设按钮=====
textbox1.text = ""
textbox2.text = ""
textbox3.text = ""
listbox1.items.clear()
//============================关闭===============
me.close()
'好了这个小软件完成了,有问题的话留言
'本程序在.net framework 2003创建