在SQL中打开连接 [英] To open connection in SQL

查看:77
本文介绍了在SQL中打开连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
在我的Web应用程序中,我的网页业务具有数据库连接性
逻辑部分,即在newproject.aspx.vb页面中.我想使用
打开连接 ADODB,我也有ADODB的记录集.我的数据库在SQL Server 2008中.
企业版.当使用代码行来打开连接时
我把这条线如下:

Hello all,
In my web application,I am having database connectivity on my webpage bussiness
logic section i.e in newproject.aspx.vb page.I want to open connection with
ADODB and i am also having recordset of ADODB.My database is in SQL Server 2008
Enterprise edition.While exicuting the code line for opening the connection
i put the line as below:

con.Open("Provider=SQLNCLI10;" & System.Configuration.ConfigurationManager.AppSettings("strConString"))



我的strConString如下:



My strConString is as follows:

Data Source=PC4-876C2F39454\SQLEXPRESS;Initial Catalog=(name of my database);Integrated Security=True



在运行时,它将引发以下系统异常:



At that run time it throws the following system exception:

Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done



我曾尝试过以下几项:
1.



Ihad tried almost several things like following:
1.

con.ConnectionString = "ProviderName = ''System.Data.SqlClient ;'' " & System.Configuration.ConfigurationManager.AppSettings("strConString") 
Con.open()


2.

con.ConnectionString = "Driver ={SQL Server Native Client 10.0}; Server =PC4-876C2F39454\SQLEXPRESS; Initial Catalog =proses "
con.open()


3.

con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("strConString")
con.open()



发生相同的错误.如何解决问题,请注意,如果我使用旧版本的SQL Server(即SQLserver2005和SQL Server 2000)使用相同的连接字符串,则可以正常工作.

有人可以帮我解决问题吗?

在此先感谢
Yogesh



The same error occurs.How to resolve the problem,becoze the if i work with same connection strings with older versions of SQL server ie.SQLserver2005 and SQL server 2000 it works fine.

So can anybody help me to solve the problem

Thanks in advance
Yogesh

推荐答案

要为您的应用程序找到正确的连接字符串,请访问 connectionstrings.com [ ^ ]
To find correct connection string for your application, visit connectionstrings.com[^]


尝试在VS中查看连接字符串.
1)打开服务器资源管理器"窗格.
2)如果您没有与数据库的连接,请创建一个
2.1)右键单击数据连接",然后选择添加连接..."
2.2)按照对话框说明进行操作.
3)建立连接后,突出显示数据库名称,然后查看属性"窗格.
4)Connections字符串是VS正在使用的字符串,它知道它可以工作.您可以将"n"粘贴到您的设置中,也可以直接将其粘贴到应用程序中.

通常,我使用:
Try looking at the connection string in VS.
1) Open the Server Explorer pane.
2) If you do not have a connection to your database, create one
2.1) Right click on "Data connections" and select "Add Connection..."
2.2) Follow the dialog instructions.
3) Once you have your connection, highlight the database name and look at the Properties pane.
4) The Connections string is the one that VS is using, and that it knows works. You can copy''n''paste that into your settings, or application directly.

Generally, I use:
using (SqlConnection con = new SqlConnection(myConnectionString))
   {
   con.Open();
   ...
   }

只需确定即可.


这篇关于在SQL中打开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆