vb.net 与 XML 的操作[4]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 fx_blog 的 blog

  ' 建立连接
            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创建

本文关键:vb.net 与 XML 的操作
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top