- ImportsSystem.Data
- '引入数据库操作类命名空间
- ImportsSystem.Data.OleDb
- '引入ADO.NET操作命名空间
- DimMyConnectionAsNewOleDbConnection(@H_502_51@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Application.StartupPath&@H_502_51@"/Book.mdb")'连接数据库
- DimMyCommandAsOleDbCommand'执行命令
- DimMyReaderAsOleDbDataReader'读取数据
- DimsqlAsString=@H_502_51@"SELECT略……"
- Try'错误时处理
- MyConnection.Open()'连接数据库
- MyCommand=NewOleDbCommand(sql,MyConnection)
- MyCommand.ExecuteNonQuery()'执行sql代码
- CatchcAsException
- MsgBox(c.ToString,MsgBoxStyle.OkOnly,@H_502_51@"错误")
- EndTry
- MyConnection.Close()'关闭
- MyCommand.Dispose()'删除