I’m building a website, and I am trying to create a connection to the database. Here is the Connection code in my web.config file:
<add name="DBX" connectionString="Data Source=localhost;Initial Catalog=DATABASE;User Id=USER;Password=PASSWORD" providerName="SqlDataSource" />
And this is the code I’m using in the code behind page:
Protected Conn As New System.Data.SqlClient.SqlConnection("DBX")
When I go to view the web page, I get the following error:
Format of the initialization string
does not conform to specification
starting at index 0.
And this highlights the Connection string in the VB.NET code behind page. I’ve checked the details of the original connection string contained within the web.config file, and I’ve used the ConnectionStrings.com website for the actual code. I’m at a loss to explain or to figure out why this isn’t working?
Many thanks!
"DBX"is not the correct format for a ConnectionString 😉What you really wanted is the ConnectionString section of your DBX-Connection in the web.config: