Last post Apr 05, 2017 02:18 PM by PatriceSc
Apr 05, 2017 02:03 PM|RateFor|LINK
The following code fragment works fine in asp.net, but fails when I put it into a regular desktop vb program. In fact, it gives me an error message. Is there some difference in how they connect to databases?
Here is the code
Dim strConnection As String = "Data Source=s05.failsafe.com;Initial Catalog=OB_4444_remake;User ID=OB_4444_remake_user;Password=Grassy88 " & Chr(34) & " providerName= " & Chr(34) & "System.Data.SqlClient"
' note that the above is not the real password, since this is a public forum
' also note that the string would be in a web.config file in an asp.net project. This fragment is regular vb adaptation.
Dim strSelect As String = "MetaGetProc"
thelist = New List(Of dbaseClass)
Dim Conn As New SqlConnection(strConnection)
Dim cmd As New SqlCommand()
cmd.Connection = Conn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = strSelect
The error I get is:
Message=Login failed for user 'OB_4444_remake_user'.
Source=.Net SqlClient Data Provider
Apr 05, 2017 02:18 PM|PatriceSc|LINK
The providerName is not part of the connectionString. So it should be rather :
Dim strConnection As String = "Data Source=s05.failsafe.com;Initial Catalog=OB_4444_remake;User ID=OB_4444_remake_user;Password=Grassy88"