VBNET数据库编程基础教程(11)
发布时间:2021-06-07
发布时间:2021-06-07
Private components As ponentModel.Container
Public Sub New()
MyBase.New()
GetConnected() '这个过程是用于建立连接,打开数据库
InitializeComponent()
End Sub
'清除在程序中使用过的资源
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) ……(省略部分自动生成代码)
End Sub
'
'为GetConnected()方法增加代码,用来打开数据表,返回数据集。
Public Sub GetConnected()
'创建一个 OleDbConnection
Dim ConnectionString As String = ″ Provider = Microsoft.Jet.OLEDB.4.0; Data Source = e:\My Documents\db1.mdb″
Dim myConn As OleDbConnection = New OleDbConnection()
myConn.ConnectionString = ConnectionString
Dim strCom As String = ″ SELECT * FROM student ″
'创建一个 DataSet
myDataSet = New DataSet()
myConn.Open()
'用 OleDbDataAdapter 得到一个数据集
Dim myCommand As OleDbDataAdapter = New OleDbDataAdapter(strCom, myConn)
上一篇:国内养老地产发展模式研究