- ImportsSystem.Data.OleDb'引入ADO.NET操作命名空间
- DimMyConnectionAsNewOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Application.StartupPath&"/Book.mdb")
- DimMyCommandAsOleDbCommand
- DimMyReaderAsOleDbDataReader
- DimdbsetAsNewDataSet'数据集合
- DimdataAAsOleDbDataAdapter'数据组
- DimsqlAsString="SELECT*FROMBookWHEREBookNameLIKE'%"&&"%'""
- SELECT*FROMBookWHEREBookSHLIKE'%"&TxtStr.Text&"%'"
- UPDATEBookSETBookAuthor='"&&"',BookName='"&&"'"WHEREID="
- INSERTINTOBook(BookSH,BookAuthor)VALUES('"&&"','"&&"')
- Try
- dbset.Clear()'数据组清除
- MyConnection.Open()
- MyCommand=NewOleDbCommand(sql,MyConnection)
- dataA=NewOleDbDataAdapter(MyCommand)
- dataA.Fill(dbset,"Book")'填充数据组
- DataGridView.DataSource=dbset.Tables("Book")'设置数据表的数据源
- CatchcAsException
- MsgBox(c.ToString,MsgBoxStyle.OkOnly,"错误")
- EndTry
- MyConnection.Close()
- MyCommand.Dispose()