Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Severe error using SQL7 & ADO.Net

Status
Not open for further replies.

JohnnyLong

Programmer
Sep 27, 2002
97
GB
I'm filling a dataset using ADO.Net and a stored procedure. But I'm getting the error message: "A severe error occurred on the current command. The results, if any, should be discarded."


Strangely, the stored proc works perfectly in the Query Analyzer and if I duplicate the query in MS Access.

Here's my ADO.Net code:

Code:
Dim scDiaryEvent As New SqlCommand
    Dim daDiaryEvent As New SqlDataAdapter
    Dim cnDiaryEvent As New SqlConnection

    'Set the connection string
     cnDiaryEvent.ConnectionString = gstrConnectionString

    'Set up the command object
     With scDiaryEvent
         .CommandText = "sp_DiaryEventFetch"
         .CommandType = CommandType.StoredProcedure
         .Connection = cnDiaryEvent
         .CommandTimeout = 0
     End With

    'Set up the dataadapter
     daDiaryEvent.SelectCommand = scDiaryEvent

    'Get the record
     dsDiaryEvent.Clear()
     Try
        daDiaryEvent.Fill(dsDiaryEvent, "EventList")
        Catch ex As SqlException
            MsgBox(ex.Message)
     End Try

        dgEvents.DataSource = dsDiaryEvent.Tables("EventList")
        daDiaryEvent.Dispose()
        cnDiaryEvent.Close()

AND the Stored Proc:

CREATE PROCEDURE dbo.sp_DiaryEventFetch

AS

BEGIN

SELECT TOP 10000 rc_Events.EventID, rc_Events.EventType, rc_Events.Subject, rc_Events.CompletedFlag, rc_Calls.CallDate, rc_Events.CreatedDate, rc_Events.ModifiedDate, rc_Events.CreatedBy, rc_Events.ModifiedBy

FROM rc_Events

LEFT JOIN rc_Calls ON rc_Events.EventID = rc_Calls.CallID

ORDER BY rc_Events.ModifiedDate DESC

END

Such a non-specific error I don't know if it's the .Net or the Sql causing the problem. Any ideas?

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top