谁会vb连sql server 数据库?
我从一本书上把vb的代码拷下来了。现在想连sqlserver数据库。但是连不上。输入用户名和密码后报错:“无法获得连接句柄"。谁能指导我把数据库连上?谢谢...
我从一本书上把vb的代码拷下来了。现在想连sql server数据库。但是连不上。输入用户名和密码后报错:“无法获得连接句柄"。谁能指导我把数据库连上?谢谢
展开
2个回答
展开全部
Dim connectingstring As String
Dim Conn As SqlConnection
Dim myCmd As SqlClient.SqlCommand
Dim myAdapter As SqlDataAdapter
connectingstring = "server=127.0.0.1;database=northwind;User ID=sa;password="
Dim commandtext As String
Conn = New SqlConnection(connectingstring)
commandtext = "select * from orders"
myAdapter = New SqlDataAdapter(commandtext, Conn)
Dim myds = New DataSet
myAdapter.Fill(myds)
DataGrid1.DataSource = myds
DataGrid1.DataBind()
Dim Conn As SqlConnection
Dim myCmd As SqlClient.SqlCommand
Dim myAdapter As SqlDataAdapter
connectingstring = "server=127.0.0.1;database=northwind;User ID=sa;password="
Dim commandtext As String
Conn = New SqlConnection(connectingstring)
commandtext = "select * from orders"
myAdapter = New SqlDataAdapter(commandtext, Conn)
Dim myds = New DataSet
myAdapter.Fill(myds)
DataGrid1.DataSource = myds
DataGrid1.DataBind()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询