主题:菜鸟问题
kskksk
[专家分:620] 发布于 2005-10-26 23:15:00
怎么在vb.net中访问一个sql server的数据库文件并读取到textbox里。
最好是给一个例子。
谢谢!!
回复列表 (共1个回复)
沙发
gzssky [专家分:10] 发布于 2005-10-27 09:52:00
Sub Page_Load(Src As Object, E As EventArgs)
'连接数据库
Dim myConnection As SqlConnection = New SqlConnection( conn )
myConnection.Open()
Dim strSQL1 As String = "SQL语句"
Dim myAdapter As New SqlDataAdapter(strSQL1,myConnection)
Dim myDataSet As New DataSet()
myAdapter.Fill(myDataSet,"dt")
Dim row As DataRow
Dim aaa As Integer
For Each row in myDataSet.Tables("dt").Rows
a=row("所需数据")
Next
myConnection.Close()
textbox1.text=aaa
End Sub
我来回复