I've been developing a web application on my workstation and have been using the code below to query a SQL Server 2005 database. I've always grabbed the connection string information from the web.config and have never had any problems. We have recently upgraded our production environment to a multiple server system that is behind a network load balancer. I'm wondering if this has anything to do with this error message. Please see code below.
Thanks for any help and/or suggestions.
Adam
btnSave_Click Event:
Dim ncVerify As New clsLocVerify(strCity, strState)
Dim verResults As String = ncVerify.VerifyCityState()
clsLocVerify:
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections.Generic
Public Class clsLocVerify
Private m_City As String
Private m_State As String
Public Sub New(ByVal city As String, ByVal state As String)
m_City = city
m_State = state.Trim().ToUpper()
End Sub
Public Function VerifyCityState() As String
Dim holderCity, holderState As New List(Of String)
Dim strConnString As String
strConnString = System.Configuration.ConfigurationManager.ConnectionStrings("GI_DATA_ConnStr").ConnectionString
If strConnString = "" Then
Return "Unable to Establish Connection with Database"
Exit Function
End If
Dim sqlConn As New SqlConnection()
sqlConn.ConnectionString = strConnString
Dim cmd As New SqlCommand
'****************************************************************check city
cmd.CommandText = "SELECT * FROM us_crush WHERE city = '" & m_City & "'"
cmd.CommandType = CommandType.Text
cmd.Connection = sqlConn
sqlConn.Open()
Dim rdr As SqlDataReader
rdr = cmd.ExecuteReader.
..and so on.