Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 A severe error occurred on the current command.

Author  Topic 

MsLady
Starting Member

5 Posts

Posted - 2009-02-11 : 09:22:06
This is a two part request; part I - error with a sql set application role stored procedure, sp_setapprole, part II - when the user enters an incorrect ID number, receives the appropriate error message, then enters the correct ID number the error message pops up again and again until I refresh the page.

I am using SQL 2005, SP3.
In my .NET (VB) app, I am connecting with approles.
The first time the page load it does so without error however, when the user enters an incorrect ID number and receives the error message via an AJAX ModalPopupExtender then the dreaded "A severe error occurred on the current command...." appears. Which only disappear when I refresh the page multiple times.

My code:
Part I
Page_Load
Dim stprocCommand As New SqlClient.SqlCommand
stprocCommand.Connection = sqlcon
stprocCommand.CommandText = "sp_setapprole"
stprocCommand.CommandType = CommandType.StoredProcedure

Dim rolename As SqlClient.SqlParameter = stprocCommand.Parameters.Add("@rolename", SqlDbType.VarChar, 20)
rolename.Value = "Rolename"

Dim password As SqlClient.SqlParameter = stprocCommand.Parameters.Add("@password", SqlDbType.VarChar, 20)
password.Value = "password"

'Open connection
sqlcon.Open()

stprocCommand.ExecuteNonQuery()<==Is where the indication of the error.
End

Part II
Sub btnSubmit
Dim cmdRtnValue As SqlCommand = New SqlCommand

cmdRtnValue.CommandType = CommandType.StoredProcedure

cmdRtnValue.CommandText = "usp_GetID"

cmdRtnValue.Parameters.AddWithValue("@ID", txtID.Text)
cmdRtnValue.Parameters.AddWithValue("@WINNT", Session("WINNT"))

cmdRtnValue.Connection = sqlcon

lblName.Text = cmdRtnValue.ExecuteScalar().ToString()

If lblName.Text.ToString = "0" Then
Me.ModalPopupExtender1.Enabled = True
Session("Tracking") = "0"
Me.ModalPopupExtender1.Show()
txtID.Text = String.Empty
End If

If lblName.Text.ToString = "1" Then
Session("Tracking") = "1"
Response.Redirect("Type.aspx")
End If

cmdRtnValue.Connection.Close()
End
***

Ought I include a cookie in th estored procedure (sp_aetapprole), if so, how?

Thank you.

MsLady
   

- Advertisement -