Click here to Skip to main content
15,561,011 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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;")


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:

VB
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()


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.
Posted

Try

Dim objConn As SqlClient.SqlConnection = New SqlConnection("Data Source=my_server; Initial Catalog=ASSET_TEST; User Id=thisapp; Password=nottherealone;")
 
Share this answer
 
Comments
iris.frigole 10-Aug-11 22:50pm    
Yes... Data Source instead of Source did the trick! Thank you!
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"
 
Share this answer
 
Comments
iris.frigole 10-Aug-11 22:50pm    
Yes!
Instead of DataSource you used Source and as a result you got this error message...
 
Share this answer
 
 
Share this answer
 
Comments
iris.frigole 10-Aug-11 22:51pm    
Long thread that I did not read, as the 1st reply solved my problem, but thanks for providing the link in Spanish!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900