G
Guest
Hi there,
I have been having a nightmare with one of ASP .Net 2.0 app which works fine
in our development environment. WHen I move to the production server the
database is getting wacked. I am trying to establish a connection thro a XML
string. Everything works fine and I am able to connect to the specific
database and make queries with that connection object. But once I move to the
production server and try to connect to a specific database I am getting
screwed. It is establishing the database connection correctly in the
prodcution server but when I execute a query it returns 0 and I dont know
where I am going wrong. I am attaching herewith code snippet which is
misbehaving in the production server.
Sub getAWPRODDBValues()
Dim cmd As New SqlCommand
Dim magStatus As String = ""
Dim mag3dStatus As String = ""
Dim strException As String = ""
Dim rs As SqlDataReader
Try
con = New SqlConnection(Session("ConnString").ToString)
con.Open()
Catch ex As Exception
strException = "Error.aspx?Exception=" & ex.Message
Response.Redirect(strException)
Return
End Try
Response.Write("Connection String from AWPROD" &
Session("ConnString").ToString)
cmd = New SqlCommand("select status,GU_MsgCount,alt_msgcount from
CP_componentDetails where comp_id=2 and Control_Type='MAG3D'", con)
rs = cmd.ExecuteReader()
If (rs.Read) Then
CylMag3DAlert.Message = "Status :" & rs.GetString(0) &
"<br/>Messages : " + rs.GetValue(2).ToString
CylMag3DGU.Message = "Status :" & rs.GetString(0) &
"<br/>Messages : " + rs.GetValue(1).ToString
Response.Write("No of messages in MAG 3D Queue" &
rs.GetValue(1).ToString)
Else
CylMag3DAlert.Message = "Status :Not Running or <br/>it is in
Idle state"
CylMag3DGU.Message = "Status :Not Running or <br/> it is in Idle
state"
End If
cmd.Dispose()
rs.Close()
cmd = New SqlCommand("select status,GU_MsgCount,alt_msgcount from
CP_componentDetails where comp_id=2 and Control_Type='MAG'", con)
rs = cmd.ExecuteReader()
If (rs.Read) Then
CylMagAlertQueue.Message = "Status :" & rs.GetString(0) &
"<br/>Messages : " + rs.GetValue(2).ToString
CylMagGUQueue.Message = "Status :" & rs.GetString(0) &
"<br/>Messages : " + rs.GetValue(1).ToString
Else
CylMagAlertQueue.Message = "Status :Not Running or <br/> it is
in Idle state"
CylMagGUQueue.Message = "Status :Not Running or <br/> it is in
Idle state"
End If
cmd.Dispose()
rs.Close()
cmd = New SqlCommand("select status from CP_ComponentDetails where
Comp_Id=1 and Control_Type='MAG'", con)
rs = cmd.ExecuteReader()
If (rs.Read) Then
magStatus = "MAG Status :" & rs.GetString(0)
End If
cmd.Dispose()
rs.Close()
cmd = New SqlCommand("select status from CP_ComponentDetails where
Comp_Id=1 and Control_Type='MAG3D'", con)
rs = cmd.ExecuteReader()
If (rs.Read) Then
mag3dStatus = "MAG3D Status :" & rs.GetString(0)
End If
cmd.Dispose()
rs.Close()
'RectEMailConv.Message = magStatus & "<br/>" & mag3dStatus
cmd = New SqlCommand("select status from CP_componentDetails where
comp_id=3 and Control_Type='MAG3D'", con)
rs = cmd.ExecuteReader()
If (rs.Read) Then
CylMag3DGUParser.Message = "Status : " + rs.GetString(0)
CylMag3DAlertParser.Message = "Status :" & rs.GetString(0)
End If
cmd.Dispose()
rs.Close()
cmd = New SqlCommand("select status from CP_componentDetails where
comp_id=3 and Control_Type='MAG'", con)
rs = cmd.ExecuteReader()
If (rs.Read) Then
CylMagGUParser.Message = "Status : " + rs.GetString(0)
CylMagAlertParser.Message = "Status :" & rs.GetString(0)
End If
cmd.Dispose()
rs.Close()
con.Close()
End Sub
Here the Session("ConnString").ToString value gets different Database
connection values (there are three servers). I am able to set the correct
value in the session.
But when the SQL statement gets executed in one server I am getting always 0
value. But in other servers I get the correct information. Is there any way I
can track this problem down.
Thanks
Any help would be greatly appreciated.
John
I have been having a nightmare with one of ASP .Net 2.0 app which works fine
in our development environment. WHen I move to the production server the
database is getting wacked. I am trying to establish a connection thro a XML
string. Everything works fine and I am able to connect to the specific
database and make queries with that connection object. But once I move to the
production server and try to connect to a specific database I am getting
screwed. It is establishing the database connection correctly in the
prodcution server but when I execute a query it returns 0 and I dont know
where I am going wrong. I am attaching herewith code snippet which is
misbehaving in the production server.
Sub getAWPRODDBValues()
Dim cmd As New SqlCommand
Dim magStatus As String = ""
Dim mag3dStatus As String = ""
Dim strException As String = ""
Dim rs As SqlDataReader
Try
con = New SqlConnection(Session("ConnString").ToString)
con.Open()
Catch ex As Exception
strException = "Error.aspx?Exception=" & ex.Message
Response.Redirect(strException)
Return
End Try
Response.Write("Connection String from AWPROD" &
Session("ConnString").ToString)
cmd = New SqlCommand("select status,GU_MsgCount,alt_msgcount from
CP_componentDetails where comp_id=2 and Control_Type='MAG3D'", con)
rs = cmd.ExecuteReader()
If (rs.Read) Then
CylMag3DAlert.Message = "Status :" & rs.GetString(0) &
"<br/>Messages : " + rs.GetValue(2).ToString
CylMag3DGU.Message = "Status :" & rs.GetString(0) &
"<br/>Messages : " + rs.GetValue(1).ToString
Response.Write("No of messages in MAG 3D Queue" &
rs.GetValue(1).ToString)
Else
CylMag3DAlert.Message = "Status :Not Running or <br/>it is in
Idle state"
CylMag3DGU.Message = "Status :Not Running or <br/> it is in Idle
state"
End If
cmd.Dispose()
rs.Close()
cmd = New SqlCommand("select status,GU_MsgCount,alt_msgcount from
CP_componentDetails where comp_id=2 and Control_Type='MAG'", con)
rs = cmd.ExecuteReader()
If (rs.Read) Then
CylMagAlertQueue.Message = "Status :" & rs.GetString(0) &
"<br/>Messages : " + rs.GetValue(2).ToString
CylMagGUQueue.Message = "Status :" & rs.GetString(0) &
"<br/>Messages : " + rs.GetValue(1).ToString
Else
CylMagAlertQueue.Message = "Status :Not Running or <br/> it is
in Idle state"
CylMagGUQueue.Message = "Status :Not Running or <br/> it is in
Idle state"
End If
cmd.Dispose()
rs.Close()
cmd = New SqlCommand("select status from CP_ComponentDetails where
Comp_Id=1 and Control_Type='MAG'", con)
rs = cmd.ExecuteReader()
If (rs.Read) Then
magStatus = "MAG Status :" & rs.GetString(0)
End If
cmd.Dispose()
rs.Close()
cmd = New SqlCommand("select status from CP_ComponentDetails where
Comp_Id=1 and Control_Type='MAG3D'", con)
rs = cmd.ExecuteReader()
If (rs.Read) Then
mag3dStatus = "MAG3D Status :" & rs.GetString(0)
End If
cmd.Dispose()
rs.Close()
'RectEMailConv.Message = magStatus & "<br/>" & mag3dStatus
cmd = New SqlCommand("select status from CP_componentDetails where
comp_id=3 and Control_Type='MAG3D'", con)
rs = cmd.ExecuteReader()
If (rs.Read) Then
CylMag3DGUParser.Message = "Status : " + rs.GetString(0)
CylMag3DAlertParser.Message = "Status :" & rs.GetString(0)
End If
cmd.Dispose()
rs.Close()
cmd = New SqlCommand("select status from CP_componentDetails where
comp_id=3 and Control_Type='MAG'", con)
rs = cmd.ExecuteReader()
If (rs.Read) Then
CylMagGUParser.Message = "Status : " + rs.GetString(0)
CylMagAlertParser.Message = "Status :" & rs.GetString(0)
End If
cmd.Dispose()
rs.Close()
con.Close()
End Sub
Here the Session("ConnString").ToString value gets different Database
connection values (there are three servers). I am able to set the correct
value in the session.
But when the SQL statement gets executed in one server I am getting always 0
value. But in other servers I get the correct information. Is there any way I
can track this problem down.
Thanks
Any help would be greatly appreciated.
John