Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting error from help file code
Message
From
03/07/2006 19:06:37
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Getting error from help file code
Miscellaneous
Thread ID:
01133503
Message ID:
01133503
Views:
55
When I use this code from the help file:
Public Sub HowToPassParameters()
    ' Create the parameter and set the direction
    Dim param1 As IDbDataParameter = Me.CreateParameter("@result", 0)
    param1.Direction = ParameterDirection.Output

    ' Call the stored procedure and pass the parameter
    Dim cmd As IDbCommand
    Me.ExecSprocScalar("OutputParamTest", cmd, param1)

    ' Retrieve the value from the command object
    Dim param As IDbDataParameter = CType(cmd.Parameters("@result"), IDbDataParameter)
    Dim x As Integer = CInt(param.Value)
  End Sub
the 'cmd' is underlined and I get this error:

Warning 1 Variable 'cmd' is passed by reference before it has been assigned a value. A null reference exception could result at runtime. E:\VS 2005 Projects\Purchasing\MM_Purchase 2.1\Purchase Bussiness Objects\Pur_item.vb 134 40 Purchase Bussiness Objects

I think I should be initializing these to something, but I don't know what.
Can anyone tell me what I should be doing to get rid of these error messages?

Thanks.
Next
Reply
Map
View

Click here to load this message in the networking platform