Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Stored Procedure/Parameter problem

Reply
Thread Tools

Stored Procedure/Parameter problem

 
 
ElmoWatson
Guest
Posts: n/a
 
      08-04-2003
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("E mpLogin"))
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?


 
Reply With Quote
 
 
 
 
Jerry
Guest
Posts: n/a
 
      08-06-2003

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


"Marina" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > 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("E mpLogin"))
> > 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?
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with stored procedure =?Utf-8?B?SnVzdGlu?= ASP .Net 4 12-12-2008 06:47 PM
Urgent problem - Stored Procedures using Created. Tables Mike Hutton ASP .Net 2 07-12-2004 10:40 AM
Stored Procedure problem The Clansman ASP .Net 1 05-18-2004 11:32 PM
Interesting Stored Procedure Problem.. Bilbo ASP .Net 3 11-20-2003 09:31 PM
Stored Procedure Problem Leon Shaw ASP .Net 1 07-29-2003 09:19 AM



Advertisments