- ImportsSystem.Data.OleDb'引入ADO.NET操作命名空间
- DimMyConnectionAsNewOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Application.StartupPath&"/Book.mdb")
- DimMyCommandAsOleDbCommand
- DimMyReaderAsOleDbDataReader
- DimsqlAsString="SELECT略……"
- Try
- MyConnection.Open()
- MyCommand=NewOleDbCommand(sql,MyConnection)
- MyReader=MyCommand.ExecuteReader()
- WhileMyReader.Read'读取到窗口Text
- TxtAuthor.Text=MyReader("BookAuthor")
- EndWhile
- CatchcAsException
- MsgBox(c.ToString,MsgBoxStyle.Exclamation&MsgBoxStyle.OkOnly,"错误")
- EndTry
- MyConnection.Close()
- MyReader.Close()
- MyCommand.Dispose()