This is my first "code first approach" with SQL Server 2012 Express.
I'm trying to create a database but there is a problem with the connection string.
This is my connection string:
Data Source=AMBROGIO\SQLEXPRESS;Initial Catalog=TAP2014_15Project;Integrated Security=True;
This is the connection string which arrives to my setup function:
Data Source=AMBROGIO\\SQLEXPRESS;Initial Catalog=TAP2014_15Project;Integrated Security=True;
With a double \\ after the name of my Pc.
For a test I've tried to write something else as connection string and under debugging it arrives without modification (obviously it raises an error).
Someone can please help me ?
Thanks.
Filippo
Hi, sorry if I reply only now. Yes I was using the debugger to look the string.
Now the error that I have is an exception raise by my method:
db.Database.CreateIfNotExists();
error:
Exception:Thrown: "Cannot open database "TAP2014_15Project" requested by the
login. The login failed.
Login failed for user 'AMBROGIO\Filippo'."
(System.Data.SqlClient.SqlException)
A System.Data.SqlClient.SqlException was thrown: "Cannot open database
"TAP2014_15Project" requested by the login. The login failed.
Login failed for user 'AMBROGIO\Filippo'."
The following line should be in your config file:
<add name="ConnectionStringName"
providerName="System.Data.SqlClient"
connectionString="Data Source=AMBROGIO\SQLEXPRESS;Initial Catalog=TAP2014_15Project;Integrated Security=True" />
If you set the connection string from C# code then:
connectionString = @"Data Source=AMBROGIO\SQLEXPRESS;Initial Catalog=TAP2014_15Project;Integrated Security=True";
Example source.
UPDATE
As for the question about login error - there is the same issue aleady resolved. Check it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With