连接到SQL Server时出现问题 [英] Problem connecting to SQL Server
问题描述
任何人都可以帮我连接到SQL Server吗?
我是这个人的新手...这是一场耗费数小时的巨大努力&
days& ....
我正在尝试以编程方式创建SQL数据库。但是我的代码
在它开始之前停止了,并且无法建立与SQL的连接
服务器。
这是我的代码:
====================================== ============ ======
Sub MakeDatabase()
Dim cn As New SqlConnection,cmd As新的SqlCommand
Dim connect $,sql $
connect $ =" Data Source =(local);综合安全= SSPI;
初始目录=;"
cn.ConnectionString =连接$
尝试
cn.Open()
Catch ae As SqlException
MsgBox(ae.Message.ToString,MsgBoxStyle.Critical," SQL
连接")
退出Sub
结束尝试
sql $ =" CREATE DATABASE Cf"
cmd.Connection = cn
cmd.CommandText = sql $
cmd.ExecuteNonQuery()
cn.Close()
结束子
这个东西停了下来,无法连接,给我一个错误#5。错误
消息表明我安装的SQL可能不允许远程访问。
但我检查过它确实存在。我正在使用VB 2005 Express和SQL 2005
Express。
Can anyone help me connect to SQL Server???
I am new to all this... it is been a titanic struggle consuming hours &
days & ....
I am trying to create an SQL database programatically. But my code
stalls before it gets started, and can''t establish a connection to SQL
Server.
Here is my code:
================================================== ======
Sub MakeDatabase()
Dim cn As New SqlConnection, cmd As New SqlCommand
Dim connect$, sql$
connect$ = "Data Source=(local); Integrated Security=SSPI;
Initial Catalog=;"
cn.ConnectionString = Connect$
Try
cn.Open()
Catch ae As SqlException
MsgBox(ae.Message.ToString, MsgBoxStyle.Critical, "SQL
Connection")
Exit Sub
End Try
sql$ = "CREATE DATABASE Cf"
cmd.Connection = cn
cmd.CommandText = sql$
cmd.ExecuteNonQuery()
cn.Close()
End Sub
This thing stalls and can''t connect, giving me an error #5. The error
message suggest that my installed SQL might not allow "remote access".
But I checked and it does. I am using VB 2005 Express and SQL 2005
Express.
推荐答案
,sql
connect
connect
="数据源=(本地);集成安全性= SSPI;
初始目录=;"
cn.ConnectionString = Connect
= "Data Source=(local); Integrated Security=SSPI;
Initial Catalog=;"
cn.ConnectionString = Connect
这篇关于连接到SQL Server时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!