Are you calling the SP a second time, or is it wrapped in an if(!page.ispostback) block? No
What control are you displaying the data in? datagrid
Did you turn off Viewstate on that control? This may be my problem, I'm reading about viewstate as I wait for a reply. Currently, I don't know how to turn off/on viewstate.
1st working call:
Protected Sub statecond()
myID = Session.SessionID()
tempstring = Session("tempstring")
Dim sqlConn As New SqlConnection
Dim sqlComm As New SqlCommand
Dim command As New SqlCommand()
getrank()
getok()
sqlComm.Connection = sqlConn
sqlConn.ConnectionString = Session("MyString")
sqlComm.CommandText = "statecond" '-- specifying the command text
sqlComm.CommandType = CommandType.StoredProcedure '-- specifying the command text is a stored proc
With sqlComm
.Parameters.Add("@MyId", SqlDbType.VarChar, 55, myID)
.Parameters.Add("@selpubs", SqlDbType.VarChar, 100, Session("selpubs"))
.Parameters.Add("@Rank2", SqlDbType.VarChar, 1, Rank2)
.Parameters.Add("@oktype", SqlDbType.VarChar, 40, oktype)
.Parameters.Add("@oktypeor", SqlDbType.VarChar, 40, oktypeor)
.Parameters.Add("@okcat", SqlDbType.VarChar, 40, okcat)
.Parameters.Add("@okcator", SqlDbType.VarChar, 40, okcator)
.Parameters.Add("@mgetfilter", SqlDbType.Int, 4, 1)
'-- specifying the parameter directions
.Parameters("@MyId").Direction = ParameterDirection.Input
.Parameters("@selpubs").Direction = ParameterDirection.Input
.Parameters("@Rank2").Direction = ParameterDirection.Input
.Parameters("@oktype").Direction = ParameterDirection.Input
.Parameters("@oktypeor").Direction = ParameterDirection.Input
.Parameters("@okcat").Direction = ParameterDirection.Input
.Parameters("@okcator").Direction = ParameterDirection.Input
.Parameters("@mgetfilter").Direction = ParameterDirection.Input
'-- assigning values to the parameters
.Parameters("@MyId").Value = myID
.Parameters("@selpubs").Value = Session("selpubs")
.Parameters("@Rank2").Value = Rank2
.Parameters("@oktype").Value = oktype
.Parameters("@oktypeor").Value = oktypeor
.Parameters("@okcat").Value = okcat
.Parameters("@okcator").Value = okcator
.Parameters("@mgetfilter").Value = 1
End With
'-- opening the connection
command.CommandTimeout = 0
sqlConn.Open()
sqlComm.Connection = sqlConn
sqlComm.ExecuteNonQuery()
'-- executing the command
'stCount = sqlComm.ExecuteScalar ' return value
'-- close the connection
sqlConn.Close()
End Sub
Call that doesn't work:
2nd call:
Sub statecond()
myID = Session.SessionID()
tempstring = Session("tempstring")
Dim sqlConn As New SqlConnection
Dim sqlComm As New SqlCommand
Dim command As New SqlCommand()
getrank()
getok()
sqlComm.Connection = sqlConn
sqlConn.ConnectionString = Session("MyString")
sqlComm.CommandText = "statecond" '-- specifying the command text
sqlComm.CommandType = CommandType.StoredProcedure '-- specifying the command text is a stored proc
With sqlComm
'-- adding the parameters
.Parameters.Add("@MyId", SqlDbType.VarChar, 55, myID)
.Parameters.Add("@selpubs", SqlDbType.VarChar, 100, Session("selpubs"))
.Parameters.Add("@Rank2", SqlDbType.VarChar, 1, rank2)
.Parameters.Add("@oktype", SqlDbType.VarChar, 40, oktype)
.Parameters.Add("@oktypeor", SqlDbType.VarChar, 40, oktypeor)
.Parameters.Add("@okcat", SqlDbType.VarChar, 40, okcat)
.Parameters.Add("@okcator", SqlDbType.VarChar, 40, okcator)
.Parameters.Add("@mgetfilter", SqlDbType.Int, 4, 1)
'-- specifying the parameter directions
.Parameters("@MyId").Direction = ParameterDirection.Input
.Parameters("@selpubs").Direction = ParameterDirection.Input
.Parameters("@Rank2").Direction = ParameterDirection.Input
.Parameters("@oktype").Direction = ParameterDirection.Input
.Parameters("@oktypeor").Direction = ParameterDirection.Input
.Parameters("@okcat").Direction = ParameterDirection.Input
.Parameters("@okcator").Direction = ParameterDirection.Input
.Parameters("@mgetfilter").Direction = ParameterDirection.Input
'-- assigning values to the parameters
.Parameters("@MyId").Value = myID
.Parameters("@selpubs").Value = Session("selpubs")
.Parameters("@Rank2").Value = rank2
.Parameters("@oktype").Value = oktype
.Parameters("@oktypeor").Value = oktypeor
.Parameters("@okcat").Value = okcat
.Parameters("@okcator").Value = okcator
.Parameters("@mgetfilter").Value = 1
End With
'-- opening the connection
sqlConn.Open()
sqlComm.Connection = sqlConn
sqlComm.ExecuteNonQuery()
'-- executing the command
'stCount = sqlComm.ExecuteScalar ' return value
'-- close the connection
sqlConn.Close()
End Sub