Home >Database >Mysql Tutorial >How to Fix the 'Keyword not supported: 'datasource'' Error When Connecting to an MDF Database in C#?
Connecting to an MDF Database File with C#
When working with C# applications, connecting to an MDF database can be encountered. This guide addresses the issue of an exception encountered when defining a connection string when attempting to connect to an MDF database file.
The error message "Keyword not supported: 'datasource'" indicates a problem with the connection string. To resolve this issue, it is necessary to add a space between the words "Data" and "Source" in the connection string.
Here's a corrected version of the connection string provided in the question:
con.ConnectionString = @"Data Source=.\SQLEXPRESS; AttachDbFilename=c:\folder\SampleDatabase.mdf; Integrated Security=True; Connect Timeout=30; User Instance=True";
Notice the space between "Data" and "Source" in the corrected connection string. After making this change, the application should be able to connect to the MDF database without encountering the "Keyword not supported: 'datasource'" exception.
The above is the detailed content of How to Fix the 'Keyword not supported: 'datasource'' Error When Connecting to an MDF Database in C#?. For more information, please follow other related articles on the PHP Chinese website!