与SqlClient.SqlConnection一起使用的SQL Server Express连接字符串 [英] SQL Server Express connection string to use with SqlClient.SqlConnection
问题描述
大家好!
我已经对此进行了Google搜索,甚至检查了 http://www.connectionstrings.com/ [
Hi everyone!
I have googled this and even checked http://www.connectionstrings.com/[^]... but it seems I am having a really slow day, so please bear me.
I am trying to connect to an SQL Server Express database using System.Data.SqlClient.SqlTransaction (*)
So, this is the connection string I am using:
Dim objConn As SqlClient.SqlConnection = New SqlConnection("Source=my_server; Initial Catalog=ASSET_TEST; User Id=thisapp; Password=nottherealone;")
引发异常:
"Palabra不承认任何来源:"来源."
夹心翻译成
未添加关键字:源"."
但是,如果我使用以下命令连接到相同的数据库,一切都会顺利进行:
Exception is raised:
"Palabra clave no admitida: ''source''."
wich translates into
"Keyword not addmited: ''source''."
However, everything goes just fine if I connect to the same database using:
Dim objCon As OleDbConnection = Nothing
Dim sCnn As String
Try
sCnn = "Provider=SQLOLEDB;Data Source=my_server;Initial Catalog=ASSET_TEST;User Id=thisapp;Password=nottherealone"
objCon = New OleDbConnection(sCnn)
objCon.Open()
有人知道第一个连接字符串有什么问题吗?
感谢您阅读我的超长问题!
(*)我希望这是可能的,因为MSDN指出"System.Data.SqlClient命名空间是SQL Server的.NET Framework数据提供程序" ...并且希望它也包括快速版本.
Does anyone know what''s wrong with the first connection string?
Thank you for reading my super long question!
(*) I hope this is possible as MSDN states that "The System.Data.SqlClient namespace is the.NET Framework Data Provider for SQL Server" ... and I hope it includes the express edition as well.
推荐答案
尝试
Try
Dim objConn As SqlClient.SqlConnection = New SqlConnection("Data Source=my_server; Initial Catalog=ASSET_TEST; User Id=thisapp; Password=nottherealone;")
这是我使用的示例;
connectionString ="Data Source =.\ SQLEXPRESS; initial catalog = JAXCODERDB; Integrated Security = SSPI; User Instance = False" providerName ="System.Data.SqlClient"
This is an example of what I use;
connectionString="Data Source=.\SQLEXPRESS;initial catalog=JAXCODERDB;Integrated Security=SSPI;User Instance=False" providerName="System.Data.SqlClient"
代替您使用的DataSource来源,因此您收到此错误消息...
Instead of DataSource you used Source and as a result you got this error message...
这篇关于与SqlClient.SqlConnection一起使用的SQL Server Express连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!