473,414 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Expected parameter error

I am getting an error when I try to call my stored procedure. Exception
adding account. Procedure 'stpCFSPH_CM_RGST_USER' expects parameter
'@USER_DESCR', which was not supplied.

I have a radio button list w/ two items, Student w/ a value of 2 and
PrivUser w/ a value of 3. What I do on the click 'Submit' button is set all
of the variables and pass them to my Admin class. Below is specifically
what I define for the userRole (what I am getting the error on)
Dim userRole As Integer = radUserList.SelectedItem.Value

Admin.StoreAccountDetails(txtUserName.Text, passwordHash, salt, tempAnswer,
qstn, userRole)

Here is my Admin.StoreAccountDetails code:

Dim conn As SqlConnection = New SqlConnection(GetConn.GetCnxString())

Dim cmd As SqlCommand = New SqlCommand("stpCFSPH_CM_RGST_USER", conn)

cmd.CommandType = CommandType.StoredProcedure

Dim sqlParam As SqlParameter = Nothing

[ALL OF THE OTHER PARAMS GO HERE, LEFT OUT FOR CLARITY]

sqlParam = cmd.Parameters.Add("@USER_DESCR", SqlDbType.Int, 10)

sqlParam.Value = userDescr

Try

conn.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

' Code to check for primary key violation (duplicate account name)

' or other database errors omitted for clarity

Throw New Exception("Exception adding account. " + ex.Message)

Finally

conn.Close()

End Try



Nov 19 '05 #1
5 1337
Can you post SQL Script that defines the stored procedure
'stpCFSPH_CM_RGST_USER' ?
Thanks
--
Gopal Rangaswamy
Microsoft Certified Solutions Developer
FMS, Inc.
<http://www.fmsinc.com/consulting>
<http://www.fmsinc.com/dotnet/SourceBook/>

"Andy G" <aj*****@iastate.edu> wrote in message
news:er**************@tk2msftngp13.phx.gbl...
I am getting an error when I try to call my stored procedure. Exception
adding account. Procedure 'stpCFSPH_CM_RGST_USER' expects parameter
'@USER_DESCR', which was not supplied.

I have a radio button list w/ two items, Student w/ a value of 2 and
PrivUser w/ a value of 3. What I do on the click 'Submit' button is set all of the variables and pass them to my Admin class. Below is specifically
what I define for the userRole (what I am getting the error on)
Dim userRole As Integer = radUserList.SelectedItem.Value

Admin.StoreAccountDetails(txtUserName.Text, passwordHash, salt, tempAnswer, qstn, userRole)

Here is my Admin.StoreAccountDetails code:

Dim conn As SqlConnection = New SqlConnection(GetConn.GetCnxString())

Dim cmd As SqlCommand = New SqlCommand("stpCFSPH_CM_RGST_USER", conn)

cmd.CommandType = CommandType.StoredProcedure

Dim sqlParam As SqlParameter = Nothing

[ALL OF THE OTHER PARAMS GO HERE, LEFT OUT FOR CLARITY]

sqlParam = cmd.Parameters.Add("@USER_DESCR", SqlDbType.Int, 10)

sqlParam.Value = userDescr

Try

conn.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

' Code to check for primary key violation (duplicate account name)

' or other database errors omitted for clarity

Throw New Exception("Exception adding account. " + ex.Message)

Finally

conn.Close()

End Try



Nov 19 '05 #2
I would first reverse the logic so you can query things:

Dim sqlParam As SqlParameter
sqlParam = ("@USER_DESCR", SqlDbType.Int, 10)
sqlParam.Value = userDescr
cmd.Parameters.Add(sqlParam)

'Repeat for other parameters (in order preferably)

This gives you a bit more control over what is happening, as you can set a
breakpoint and query items.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Andy G" wrote:
I am getting an error when I try to call my stored procedure. Exception
adding account. Procedure 'stpCFSPH_CM_RGST_USER' expects parameter
'@USER_DESCR', which was not supplied.

I have a radio button list w/ two items, Student w/ a value of 2 and
PrivUser w/ a value of 3. What I do on the click 'Submit' button is set all
of the variables and pass them to my Admin class. Below is specifically
what I define for the userRole (what I am getting the error on)
Dim userRole As Integer = radUserList.SelectedItem.Value

Admin.StoreAccountDetails(txtUserName.Text, passwordHash, salt, tempAnswer,
qstn, userRole)

Here is my Admin.StoreAccountDetails code:

Dim conn As SqlConnection = New SqlConnection(GetConn.GetCnxString())

Dim cmd As SqlCommand = New SqlCommand("stpCFSPH_CM_RGST_USER", conn)

cmd.CommandType = CommandType.StoredProcedure

Dim sqlParam As SqlParameter = Nothing

[ALL OF THE OTHER PARAMS GO HERE, LEFT OUT FOR CLARITY]

sqlParam = cmd.Parameters.Add("@USER_DESCR", SqlDbType.Int, 10)

sqlParam.Value = userDescr

Try

conn.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

' Code to check for primary key violation (duplicate account name)

' or other database errors omitted for clarity

Throw New Exception("Exception adding account. " + ex.Message)

Finally

conn.Close()

End Try



Nov 19 '05 #3
Here is the Stored Proc...

CREATE PROCEDURE dbo.stpCFSPH_CM_RGST_USER

@LOGIN_NAME VARCHAR(255),
@PSWRD VARCHAR(40),
@SALT VARCHAR(10),
@ANSWER VARCHAR(50),
@QSTN_ID INT,
@USER_DESCR INT

AS
SET NOCOUNT ON

DECLARE @PRSN_ID INT

BEGIN
INSERT INTO dbo.tblCFSPH_CM_LOGIN (LOGIN_NAME, PSWRD, SALT, ANSWER, QSTN_ID)
VALUES(@LOGIN_NAME, @PSWRD, @SALT, @ANSWER, @QSTN_ID)
END

BEGIN
SELECT @PRSN_ID = SCOPE_IDENTITY()
END

BEGIN
INSERT INTO dbo.tblCFSPH_CM_PRSN_ROLE_LINK(PRSN_ID, ROLE_ID)
VALUES (@PRSN_ID, @USER_DESCR)
END

"Gopal (FMS, Inc.)" <go**********@fmsinc.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
Can you post SQL Script that defines the stored procedure
'stpCFSPH_CM_RGST_USER' ?
Thanks
--
Gopal Rangaswamy
Microsoft Certified Solutions Developer
FMS, Inc.
<http://www.fmsinc.com/consulting>
<http://www.fmsinc.com/dotnet/SourceBook/>

"Andy G" <aj*****@iastate.edu> wrote in message
news:er**************@tk2msftngp13.phx.gbl...
I am getting an error when I try to call my stored procedure. Exception
adding account. Procedure 'stpCFSPH_CM_RGST_USER' expects parameter
'@USER_DESCR', which was not supplied.

I have a radio button list w/ two items, Student w/ a value of 2 and
PrivUser w/ a value of 3. What I do on the click 'Submit' button is set

all
of the variables and pass them to my Admin class. Below is specifically
what I define for the userRole (what I am getting the error on)
Dim userRole As Integer = radUserList.SelectedItem.Value

Admin.StoreAccountDetails(txtUserName.Text, passwordHash, salt,

tempAnswer,
qstn, userRole)

Here is my Admin.StoreAccountDetails code:

Dim conn As SqlConnection = New SqlConnection(GetConn.GetCnxString())

Dim cmd As SqlCommand = New SqlCommand("stpCFSPH_CM_RGST_USER", conn)

cmd.CommandType = CommandType.StoredProcedure

Dim sqlParam As SqlParameter = Nothing

[ALL OF THE OTHER PARAMS GO HERE, LEFT OUT FOR CLARITY]

sqlParam = cmd.Parameters.Add("@USER_DESCR", SqlDbType.Int, 10)

sqlParam.Value = userDescr

Try

conn.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

' Code to check for primary key violation (duplicate account name)

' or other database errors omitted for clarity

Throw New Exception("Exception adding account. " + ex.Message)

Finally

conn.Close()

End Try




Nov 19 '05 #4
Do all parameters before USER_DESCR have a value that is initialized (not
nothing)?

"Andy G" <aj*****@iastate.edu> wrote in message
news:e7**************@TK2MSFTNGP10.phx.gbl...
Here is the Stored Proc...

CREATE PROCEDURE dbo.stpCFSPH_CM_RGST_USER

@LOGIN_NAME VARCHAR(255),
@PSWRD VARCHAR(40),
@SALT VARCHAR(10),
@ANSWER VARCHAR(50),
@QSTN_ID INT,
@USER_DESCR INT

AS
SET NOCOUNT ON

DECLARE @PRSN_ID INT

BEGIN
INSERT INTO dbo.tblCFSPH_CM_LOGIN (LOGIN_NAME, PSWRD, SALT, ANSWER, QSTN_ID) VALUES(@LOGIN_NAME, @PSWRD, @SALT, @ANSWER, @QSTN_ID)
END

BEGIN
SELECT @PRSN_ID = SCOPE_IDENTITY()
END

BEGIN
INSERT INTO dbo.tblCFSPH_CM_PRSN_ROLE_LINK(PRSN_ID, ROLE_ID)
VALUES (@PRSN_ID, @USER_DESCR)
END

"Gopal (FMS, Inc.)" <go**********@fmsinc.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
Can you post SQL Script that defines the stored procedure
'stpCFSPH_CM_RGST_USER' ?
Thanks
--
Gopal Rangaswamy
Microsoft Certified Solutions Developer
FMS, Inc.
<http://www.fmsinc.com/consulting>
<http://www.fmsinc.com/dotnet/SourceBook/>

"Andy G" <aj*****@iastate.edu> wrote in message
news:er**************@tk2msftngp13.phx.gbl...
I am getting an error when I try to call my stored procedure. Exception adding account. Procedure 'stpCFSPH_CM_RGST_USER' expects parameter
'@USER_DESCR', which was not supplied.

I have a radio button list w/ two items, Student w/ a value of 2 and
PrivUser w/ a value of 3. What I do on the click 'Submit' button is set
all
of the variables and pass them to my Admin class. Below is

specifically what I define for the userRole (what I am getting the error on)
Dim userRole As Integer = radUserList.SelectedItem.Value

Admin.StoreAccountDetails(txtUserName.Text, passwordHash, salt,

tempAnswer,
qstn, userRole)

Here is my Admin.StoreAccountDetails code:

Dim conn As SqlConnection = New SqlConnection(GetConn.GetCnxString())

Dim cmd As SqlCommand = New SqlCommand("stpCFSPH_CM_RGST_USER", conn)

cmd.CommandType = CommandType.StoredProcedure

Dim sqlParam As SqlParameter = Nothing

[ALL OF THE OTHER PARAMS GO HERE, LEFT OUT FOR CLARITY]

sqlParam = cmd.Parameters.Add("@USER_DESCR", SqlDbType.Int, 10)

sqlParam.Value = userDescr

Try

conn.Open()

cmd.ExecuteNonQuery()

Catch ex As Exception

' Code to check for primary key violation (duplicate account name)

' or other database errors omitted for clarity

Throw New Exception("Exception adding account. " + ex.Message)

Finally

conn.Close()

End Try





Nov 19 '05 #5
Yes all values have been initialized. I have it working now. I've ran into
problems before declaring parameters. Sometimes a specific way that work
for one stored procedure didn't work for another one. Below is how I reset
all parameters in this class, it works now. Thanks for the help guys.

Dim paramPassHash As New SqlParameter("@PSWRD", SqlDbType.VarChar, 40)

paramPassHash.Value = passwordHash

cmd.Parameters.Add(paramPassHash)

"Gopal (FMS, Inc.)" <go**********@fmsinc.com> wrote in message
news:eF**************@TK2MSFTNGP09.phx.gbl...
Do all parameters before USER_DESCR have a value that is initialized (not
nothing)?

"Andy G" <aj*****@iastate.edu> wrote in message
news:e7**************@TK2MSFTNGP10.phx.gbl...
Here is the Stored Proc...

CREATE PROCEDURE dbo.stpCFSPH_CM_RGST_USER

@LOGIN_NAME VARCHAR(255),
@PSWRD VARCHAR(40),
@SALT VARCHAR(10),
@ANSWER VARCHAR(50),
@QSTN_ID INT,
@USER_DESCR INT

AS
SET NOCOUNT ON

DECLARE @PRSN_ID INT

BEGIN
INSERT INTO dbo.tblCFSPH_CM_LOGIN (LOGIN_NAME, PSWRD, SALT, ANSWER,

QSTN_ID)
VALUES(@LOGIN_NAME, @PSWRD, @SALT, @ANSWER, @QSTN_ID)
END

BEGIN
SELECT @PRSN_ID = SCOPE_IDENTITY()
END

BEGIN
INSERT INTO dbo.tblCFSPH_CM_PRSN_ROLE_LINK(PRSN_ID, ROLE_ID)
VALUES (@PRSN_ID, @USER_DESCR)
END

"Gopal (FMS, Inc.)" <go**********@fmsinc.com> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
Can you post SQL Script that defines the stored procedure
'stpCFSPH_CM_RGST_USER' ?
Thanks
--
Gopal Rangaswamy
Microsoft Certified Solutions Developer
FMS, Inc.
<http://www.fmsinc.com/consulting>
<http://www.fmsinc.com/dotnet/SourceBook/>

"Andy G" <aj*****@iastate.edu> wrote in message
news:er**************@tk2msftngp13.phx.gbl...
> I am getting an error when I try to call my stored procedure. Exception > adding account. Procedure 'stpCFSPH_CM_RGST_USER' expects parameter
> '@USER_DESCR', which was not supplied.
>
> I have a radio button list w/ two items, Student w/ a value of 2 and
> PrivUser w/ a value of 3. What I do on the click 'Submit' button is set all
> of the variables and pass them to my Admin class. Below is specifically > what I define for the userRole (what I am getting the error on)
> Dim userRole As Integer = radUserList.SelectedItem.Value
>
> Admin.StoreAccountDetails(txtUserName.Text, passwordHash, salt,
tempAnswer,
> qstn, userRole)
>
> Here is my Admin.StoreAccountDetails code:
>
> Dim conn As SqlConnection = New SqlConnection(GetConn.GetCnxString()) >
> Dim cmd As SqlCommand = New SqlCommand("stpCFSPH_CM_RGST_USER", conn) >
> cmd.CommandType = CommandType.StoredProcedure
>
> Dim sqlParam As SqlParameter = Nothing
>
> [ALL OF THE OTHER PARAMS GO HERE, LEFT OUT FOR CLARITY]
>
> sqlParam = cmd.Parameters.Add("@USER_DESCR", SqlDbType.Int, 10)
>
> sqlParam.Value = userDescr
>
> Try
>
> conn.Open()
>
> cmd.ExecuteNonQuery()
>
> Catch ex As Exception
>
> ' Code to check for primary key violation (duplicate account name)
>
> ' or other database errors omitted for clarity
>
> Throw New Exception("Exception adding account. " + ex.Message)
>
> Finally
>
> conn.Close()
>
> End Try
>
>
>
>
>
>
>
>
>



Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chuck Martin | last post by:
I am having a most frustrating problem that references, web searches, and other resources are no help so far in solving. Basically, I'm trying to design a pop-up window to be called with a funciton...
7
by: Dee | last post by:
Running an AfterUpdate event procedure, I get the following error: "Too few parameters. Expected 1." My code is as follows: Private Sub DealerID_AfterUpdate() Dim db As DAO.Database
1
by: bonnie.tangyn | last post by:
Hello all I get Too few parameters expected 2 error and "The MS Jet Database engine cannot find the input table or query "myTempTablename". Make sure it exists and that its name is spelled...
9
by: D. Shane Fowlkes | last post by:
Still learning ASP.NET....(and I was getting so good with classic ASP too!). I'm trying to connect to a SQL Server using a simple connection script. I've checked 2 different books and looked at...
2
by: Patrick Olurotimi Ige | last post by:
I converted the code below from VB.NET to C# cos i have to add it to a C# application!! But i'm getting the error:- System.Data.SqlClient.SqlCommand.Parameters' denotes a 'property' where a...
0
by: Saya | last post by:
Hello, The situation is as follows: My server app (ASP.NET WebService) responds to the client request (ASP.NET) by returning a text string appended with 2 int numbers, being the X&Y coordinate...
4
by: javatopia | last post by:
Hello, I am trying to show a Crystal Reports 10 Enterprise report in an ASP.NET page (C#). I can run the report via the admin console just fine. When I try to show the report, after setting up...
3
mafaisal
by: mafaisal | last post by:
End of parameter list expected. Cannot define parameters after a paramarray parameter. Public Sub F_Bind(ByVal StrSql As String, ByVal ParamArray Ctrls() As Object,Optional ByVal Row as Integer...
9
by: erictheone | last post by:
Ok so what I'm trying to do is create a trans location cipher. For those among us that don't know alot about cryptography it is a method for jumbling up letters to disguise linguistic...
0
by: jb489 | last post by:
Hi all, Hope I am posting this in the right forum. I seem to be having a problem when using serialization and web services. <b>Scenario:</b> I have built a web service which includes a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.