've installed SQL Express on my PC hoping to do some practice creating tables and then modifying them. I coded a webpage in Visual Studio to, basically, SELECT * from a table in the SQLEXPRESS, but I can never get the connection string to work. Please help
My connection string
"Data Source=localhost\SQLEXPRESS;Initial Catalog=test;User Id=xaa9-PC\xaa9;Password=abcd;"
Error Message:
Query is select * from tblCustomers where username='johndoe' error is Login failed for user 'x309-PC\x309'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Query is select * from tblCustomers where username='johndoe' error is Login failed for user 'x309-PC\x309'.
Open SQL Server Management Studio. In Connect to Server, select Database Engine, enter your SQL Server name, and enter administrator credentials to connect to the server. Select Connect. In Object Explorer, expand the SQL Server, expand Security, right-click Logins, and then select New Login.
Try using Windows authentication:
Data Source=localhost\SQLEXPRESS;Initial Catalog=test;Integrated Security=SSPI;
Try like this:
string connectionString = "Data Source=.\\SQLEXPRESS;Initial Catalog=test;User Id=x309;Password=abcd;";
Also make sure you have enabled SQL authentication.
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