Can not connect to sql-server database file
In the output-directory of my solution there's a folder named Storage. In
this folder is a Databasefile Comments.sdf located which has no password.
Now I want to connect to this database by the following code:
string connectionString = @"Data Source=\Storage\Comments.sdf;Persist
Security Info=False;";
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
The line connection.Open(); throws an exception.
I only have the german error-message:
Netzwerkbezogener oder instanzspezifischer Fehler beim Herstellen einer
Verbindung mit SQL Server. Der Server wurde nicht gefunden, oder auf ihn
kann nicht zugegriffen werden. Überprüfen Sie, ob der Instanzname richtig
ist und ob SQL Server Remoteverbindungen zulässt. (provider: SQL Network
Interfaces, error: 25 - Verbindungszeichenfolge ungültig)
In english it's like:
A network-related or instance-specific error occurred while establishing a
connection to SQL Server. The server was not found or it can not be
accessed. Verify that the instance name is correct and that SQL Server
allows remote connections. (provider: SQL Network Interfaces, error: 25 -
Connection string is invalid)
Is there anything wrong with my connectionstring or do I have to set some
properties at the databasefile?
No comments:
Post a Comment