连接到SQL Server时出现问题

编程入门 行业动态 更新时间:2024-10-18 20:32:55
本文介绍了连接到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时出现问题

本文发布于:2023-11-23 20:40:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622800.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   SQL   Server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!