Stored Procedure/Parameter problem

Discussion in 'ASP .Net' started by ElmoWatson, Aug 4, 2003.

  1. ElmoWatson

    ElmoWatson Guest

    I'm getting an error I don't understand....

    Here's my Code:


    Dim dr As SqlDataReader
    Dim retVal As Boolean = False
    Dim MySQL as string = "spGetEmployee"
    Dim Myconn as New
    SQLConnection(ConfigurationSettings.AppSettings("EmpLogin"))
    Dim Cmd as New SQLCommand(MySQL, MyConn)
    cmd.CommandType=CommandType.StoredProcedure
    cmd.parameters.add(New SQLParameter("@Login", txtUID.text))
    cmd.parameters.add(New SQLParameter("@Password", txtPWD.text))
    cmd = New SqlCommand(MySQL, MyConn)
    MyConn.Open()
    dr = cmd.ExecuteReader()

    But on that last line (executeReader), I get this error:
    Procedure 'spGetEmployee' expects parameter '@Login', which was not supplied

    What am I doing wrong?
     
    ElmoWatson, Aug 4, 2003
    #1
    1. Advertising

  2. ElmoWatson

    Jerry Guest

    Marina is correct. You can also just comment out cmd = New SqlCommand(MySQL,
    MyConn)
    line of code.


    "Marina" <> wrote in message
    news:...
    > When you say: cmd = new SqlCommand(MySQL,MyConn), this creates a new
    > SqlCommand object.
    >
    > All the parameters you set before, just got wiped out, because the object
    > you set it on, no longer exists.
    >
    > Move the parameter statements to after this constructor call.
    >
    > "ElmoWatson" <> wrote in message
    > news:%...
    > > I'm getting an error I don't understand....
    > >
    > > Here's my Code:
    > >
    > >
    > > Dim dr As SqlDataReader
    > > Dim retVal As Boolean = False
    > > Dim MySQL as string = "spGetEmployee"
    > > Dim Myconn as New
    > > SQLConnection(ConfigurationSettings.AppSettings("EmpLogin"))
    > > Dim Cmd as New SQLCommand(MySQL, MyConn)
    > > cmd.CommandType=CommandType.StoredProcedure
    > > cmd.parameters.add(New SQLParameter("@Login", txtUID.text))
    > > cmd.parameters.add(New SQLParameter("@Password", txtPWD.text))
    > > cmd = New SqlCommand(MySQL, MyConn)
    > > MyConn.Open()
    > > dr = cmd.ExecuteReader()
    > >
    > > But on that last line (executeReader), I get this error:
    > > Procedure 'spGetEmployee' expects parameter '@Login', which was not

    > supplied
    > >
    > > What am I doing wrong?
    > >
    > >

    >
    >
     
    Jerry, Aug 6, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. raymond chiu
    Replies:
    1
    Views:
    5,722
    Tushar Agarwal
    Jan 21, 2006
  2. Mona
    Replies:
    2
    Views:
    683
    Rajesh Tiwari
    Jun 27, 2003
  3. Mona
    Replies:
    1
    Views:
    911
    Tu-Thach
    Jun 27, 2003
  4. Steven
    Replies:
    5
    Views:
    5,946
    Jeff Louie
    May 27, 2004
  5. Mike P
    Replies:
    0
    Views:
    3,328
    Mike P
    Jun 19, 2006
Loading...

Share This Page