dshi15
asked on
How to write connection string to sql server in Web.config
Hi Expert,
I wrote connect string doesn't work, the error said "Login failed for user"
<add name="SysDB" connectionString="Data Source=ZBL-LT\SQLEXPRESS;I nitial Catalog=Student;Persist Security Info=True;" providerName="System.Data. SqlClient" />
Thanks in advance.
I wrote connect string doesn't work, the error said "Login failed for user"
<add name="SysDB" connectionString="Data Source=ZBL-LT\SQLEXPRESS;I
Thanks in advance.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for quick response:
I like to use windows authentication
I replaced Data Source by localhost.
<add name="SysDB" connectionString="Data Source=localhost;Initial Catalog=student;Integrated Security=True " />
But I got this error
"An exception of type 'System.Data.SqlClient.Sql Exception' occurred in System.Data.dll but was not handled in user code
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
If i use Data Source=ZBL-LT\SQLEXPRESS, it has Login failed error,
I attached a screen shot how open SSM and connect database, I didn't have password, after I click on 'connect button', it will open database.
Thank you, please give more advice.
Connection.docx
I like to use windows authentication
I replaced Data Source by localhost.
<add name="SysDB" connectionString="Data Source=localhost;Initial Catalog=student;Integrated
But I got this error
"An exception of type 'System.Data.SqlClient.Sql
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
If i use Data Source=ZBL-LT\SQLEXPRESS, it has Login failed error,
I attached a screen shot how open SSM and connect database, I didn't have password, after I click on 'connect button', it will open database.
Thank you, please give more advice.
Connection.docx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you,
<add name="SysDB" connectionString="Data Source=ZBL-LT\SQLEXPRESS;I nitial Catalog=student;Integrated Security=SSPI;" />
works.
<add name="SysDB" connectionString="Data Source=ZBL-LT\SQLEXPRESS;I
works.
SQL Server connection strings
http://www.connectionstrings.com/sql-server/
in addition, if you're using any version of Visual Studio, you can using existing wizard of Connection object to create the connection string.
How to: Create Connections to SQL Server Databases
https://msdn.microsoft.com/en-us/library/s4yys16a(v=vs.90).aspx