Strange bug (x-posted to aspdotnet, sqlserver)

    Date: 01/13/05 (SQL Server)    Keywords: sql

    I'm getting some weird behavior in a function I wrote.

    Private Function GetServerStatus() As Integer
    Dim strDataSource As String
    Dim myConnection As SqlConnection
    Dim myCommand As SqlCommand
    Dim intStatus As Integer
    strDataSource = ConfigurationSettings.AppSettings("DSN")
    myConnection = New SqlConnection(strDataSource)
    myCommand = New SqlCommand("GetSystemStatus", myConnection)
    myCommand.CommandType = CommandType.StoredProcedure
    myConnection.Open()
    intStatus = myCommand.ExecuteNonQuery()
    myConnection.Close()
    Return intStatus
    End Function

    It uses the stored procedure "GetSystemStatus":
    CREATE PROCEDURE dbo.GetSystemStatus
    AS
    DECLARE @SystemStatus int
    SELECT @SystemStatus=MAX(systemstatus)
    FROM Config
    RETURN @SystemStatus
    GO

    The weird behavior is that GetServerStatus() returns -1, but when I run GetSystemStatus in Query Analyzer, it returns 0 (or whatever the value is).

    Source: http://www.livejournal.com/community/sqlserver/15376.html

« sp_cursoropen behavior || This is rather odd... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home