1 Public Sub connect()
2 Dim conn As New SqlClient.SqlConnection("driver={SQL Server};server=PC-201105311336\SQLEXPRESS;Uid=sa;Pwd=123456;Database=jiaxiaoai")
3 Dim myDataSet As New DataSet
4 Dim sql As String
5 sql = "select * from student"
6 Dim rs As SqlClient.SqlDataAdapter
7 With rs.SelectCommand
8 .CommandText = sql
9 .CommandType = CommandType.Text
10 .Connection = conn
11 End With
12 rs.Fill(myDataSet, "student")'表student填充到dataset中
13 conn.Close()
14 End Sub
转载于:https://www.cnblogs.com/jiaxiaoai/archive/2011/08/01/2123962.html