怎么用vs2008 连接sql server 2008?
我在sql2008里建了个数据库work,然后我在vs2008里新建了网站写代码想连接数据库work,调试后连不上,并且出现这个窗口请问应该怎么解决?代码(用vb写的):...
我在sql 2008里建了个数据库work,然后我在vs2008里新建了网站写代码想连接数据库work,调试后连不上,并且出现这个窗口
请问应该怎么解决?
代码(用vb写的):
Imports System
Imports System.Data
Imports System.Data.SqlClient
Partial Class com_1
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As SqlConnection
Dim constr As String
constr = "server = localhost;database=work;uid=sa;pwd=123"
'创建SqlConnection对象
conn = New SqlConnection(constr)
'打开数据库连接
conn.Open()
Label1.Text = conn.State.ToString()
'关闭数据库连接
conn.Close()
End Sub
End Class 展开
请问应该怎么解决?
代码(用vb写的):
Imports System
Imports System.Data
Imports System.Data.SqlClient
Partial Class com_1
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As SqlConnection
Dim constr As String
constr = "server = localhost;database=work;uid=sa;pwd=123"
'创建SqlConnection对象
conn = New SqlConnection(constr)
'打开数据库连接
conn.Open()
Label1.Text = conn.State.ToString()
'关闭数据库连接
conn.Close()
End Sub
End Class 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询