I am trying to connect to SQL Server. I have two sets of connection strings. The values for both are stored in the registry. I am accessing one through this code...
Public ReadOnly Property ConfigFormW() As frmConfig
Return New frmConfig(cRegistryHive, Entities.RegistrySubKeys.Warehouse)
I call this in a Sub at ...
Dim sqlConnectionW As New SqlConnection("Server=" + basMain.ConfigFormW.ServerName + "; Database=" + basMain.ConfigFormW.DataBase + "; User ID=" + basMain.ConfigFormW.UserName + ";
Password=" + basMain.ConfigFormW.Password + "; persist security info=true;")
I have modified the Dim several ways. I have set the persist security info to false, I have not used the persist statement at all, and I have called the connection string directly as in...
Dim sqlConnectionW As New SqlConnection(basMain.ConfigFormW.ConnectionString)
Each time, when I get to the place where I am actually utilizing the string value I get the error Format of the initialization string does not conform to specification starting at index 0. The code fails at the last line of the following...
Public Function GetSecMasterPrice(ByVal cusip As String, ByVal sqlConnectionW As SqlConnection) As Decimal
Dim sqlConnection As New SqlClient.SqlConnection(sqlConnectionW.ToString())
I have searched for fixes and found references to punctuation in the string, not present in mine, and the string itself, I have tried both configurations that have been recommended. The other connection string works perfectly and is retreived through a similar
process. I am at a loss as to why this error is thrown for this connection string. I have debugged the code and found tha in all cases the correct values are present. Any suggestions?
For the error message “Format of the initialization string does not conform to specification starting at index 0”, this usually means the connection string isn't any good. If we look at the stack trace, you'll notice that this is failing when trying to interpret
the connection string.
Check the connection string “sqlConnectionW” to make sure it is correct.
Or you could share the program to us so that we can do a test on it.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
HERE to participate the survey.