Sending an Email to the user causes the error - [SqlException (0x80131904)
A severe error occurred on the current command. The results, if any, should be discarded.
Stack Trace:
[SqlException (0x80131904): A severe error occurred on the current command. The results, if any, should be discarded.]
This error is being generated when my ASP.NET 2.0 program calls a stored procedure, which sends the user an email when a new record is created. However the email is sent with no problem.
Have searched through lots of sites, but have found no solution.
The SQL Server stored procedure is as follows:
CREATE PROCEDURE dbo.spCreateLessonSendEmail
(@Receiver varchar(100),
@LessonID int)
AS
DECLARE @MessagePart varchar(45)
BEGIN
set @MessagePart = 'You have just created a new Record ID#=' + cast(@LessonID as varchar)
exec [MAILSERVERADDRESSmaster.dbo.xp_sendmail
@Recipients = @Receiver,
@Message = @MessagePart,
@Subject = 'New Record Created'
END
GO
In the ASP.NET page itself the procedure is being called through the following code:
Sub Run_spCreateLessonSendEmail()
Dim myConnection As New System.Data.SqlClient.SqlConnection(strConn)
myConnection.Open()
Dim myCommand As New System.Data.SqlClient.SqlCommand("execute dbo.StoredProcedure 'recipients.address'," + Session("Session_LessonID").ToString, myConnection)
myCommand.CommandType = Data.CommandType.Text
Dim reader As System.Data.SqlClient.SqlDataReader = myCommand.ExecuteReader()
myConnection.Close()
Server.ClearError()
End Sub
|