473,804 Members | 3,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Expected parameter error

I am getting an error when I try to call my stored procedure. Exception
adding account. Procedure 'stpCFSPH_CM_RG ST_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.Sel ectedItem.Value

Admin.StoreAcco untDetails(txtU serName.Text, passwordHash, salt, tempAnswer,
qstn, userRole)

Here is my Admin.StoreAcco untDetails code:

Dim conn As SqlConnection = New SqlConnection(G etConn.GetCnxSt ring())

Dim cmd As SqlCommand = New SqlCommand("stp CFSPH_CM_RGST_U SER", conn)

cmd.CommandType = CommandType.Sto redProcedure

Dim sqlParam As SqlParameter = Nothing

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

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

sqlParam.Value = userDescr

Try

conn.Open()

cmd.ExecuteNonQ uery()

Catch ex As Exception

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

' or other database errors omitted for clarity

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

Finally

conn.Close()

End Try



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

"Andy G" <aj*****@iastat e.edu> wrote in message
news:er******** ******@tk2msftn gp13.phx.gbl...
I am getting an error when I try to call my stored procedure. Exception
adding account. Procedure 'stpCFSPH_CM_RG ST_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.Sel ectedItem.Value

Admin.StoreAcco untDetails(txtU serName.Text, passwordHash, salt, tempAnswer, qstn, userRole)

Here is my Admin.StoreAcco untDetails code:

Dim conn As SqlConnection = New SqlConnection(G etConn.GetCnxSt ring())

Dim cmd As SqlCommand = New SqlCommand("stp CFSPH_CM_RGST_U SER", conn)

cmd.CommandType = CommandType.Sto redProcedure

Dim sqlParam As SqlParameter = Nothing

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

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

sqlParam.Value = userDescr

Try

conn.Open()

cmd.ExecuteNonQ uery()

Catch ex As Exception

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

' or other database errors omitted for clarity

Throw New Exception("Exce ption 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_DESC R", 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_RG ST_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.Sel ectedItem.Value

Admin.StoreAcco untDetails(txtU serName.Text, passwordHash, salt, tempAnswer,
qstn, userRole)

Here is my Admin.StoreAcco untDetails code:

Dim conn As SqlConnection = New SqlConnection(G etConn.GetCnxSt ring())

Dim cmd As SqlCommand = New SqlCommand("stp CFSPH_CM_RGST_U SER", conn)

cmd.CommandType = CommandType.Sto redProcedure

Dim sqlParam As SqlParameter = Nothing

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

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

sqlParam.Value = userDescr

Try

conn.Open()

cmd.ExecuteNonQ uery()

Catch ex As Exception

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

' or other database errors omitted for clarity

Throw New Exception("Exce ption 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_N AME, @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**********@f msinc.com> wrote in message
news:Oe******** ******@tk2msftn gp13.phx.gbl...
Can you post SQL Script that defines the stored procedure
'stpCFSPH_CM_RG ST_USER' ?
Thanks
--
Gopal Rangaswamy
Microsoft Certified Solutions Developer
FMS, Inc.
<http://www.fmsinc.com/consulting>
<http://www.fmsinc.com/dotnet/SourceBook/>

"Andy G" <aj*****@iastat e.edu> wrote in message
news:er******** ******@tk2msftn gp13.phx.gbl...
I am getting an error when I try to call my stored procedure. Exception
adding account. Procedure 'stpCFSPH_CM_RG ST_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.Sel ectedItem.Value

Admin.StoreAcco untDetails(txtU serName.Text, passwordHash, salt,

tempAnswer,
qstn, userRole)

Here is my Admin.StoreAcco untDetails code:

Dim conn As SqlConnection = New SqlConnection(G etConn.GetCnxSt ring())

Dim cmd As SqlCommand = New SqlCommand("stp CFSPH_CM_RGST_U SER", conn)

cmd.CommandType = CommandType.Sto redProcedure

Dim sqlParam As SqlParameter = Nothing

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

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

sqlParam.Value = userDescr

Try

conn.Open()

cmd.ExecuteNonQ uery()

Catch ex As Exception

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

' or other database errors omitted for clarity

Throw New Exception("Exce ption 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*****@iastat e.edu> wrote in message
news:e7******** ******@TK2MSFTN GP10.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_N AME, @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**********@f msinc.com> wrote in message
news:Oe******** ******@tk2msftn gp13.phx.gbl...
Can you post SQL Script that defines the stored procedure
'stpCFSPH_CM_RG ST_USER' ?
Thanks
--
Gopal Rangaswamy
Microsoft Certified Solutions Developer
FMS, Inc.
<http://www.fmsinc.com/consulting>
<http://www.fmsinc.com/dotnet/SourceBook/>

"Andy G" <aj*****@iastat e.edu> wrote in message
news:er******** ******@tk2msftn gp13.phx.gbl...
I am getting an error when I try to call my stored procedure. Exception adding account. Procedure 'stpCFSPH_CM_RG ST_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.Sel ectedItem.Value

Admin.StoreAcco untDetails(txtU serName.Text, passwordHash, salt,

tempAnswer,
qstn, userRole)

Here is my Admin.StoreAcco untDetails code:

Dim conn As SqlConnection = New SqlConnection(G etConn.GetCnxSt ring())

Dim cmd As SqlCommand = New SqlCommand("stp CFSPH_CM_RGST_U SER", conn)

cmd.CommandType = CommandType.Sto redProcedure

Dim sqlParam As SqlParameter = Nothing

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

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

sqlParam.Value = userDescr

Try

conn.Open()

cmd.ExecuteNonQ uery()

Catch ex As Exception

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

' or other database errors omitted for clarity

Throw New Exception("Exce ption 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.VarCh ar, 40)

paramPassHash.V alue = passwordHash

cmd.Parameters. Add(paramPassHa sh)

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

"Andy G" <aj*****@iastat e.edu> wrote in message
news:e7******** ******@TK2MSFTN GP10.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_N AME, @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**********@f msinc.com> wrote in message
news:Oe******** ******@tk2msftn gp13.phx.gbl...
Can you post SQL Script that defines the stored procedure
'stpCFSPH_CM_RG ST_USER' ?
Thanks
--
Gopal Rangaswamy
Microsoft Certified Solutions Developer
FMS, Inc.
<http://www.fmsinc.com/consulting>
<http://www.fmsinc.com/dotnet/SourceBook/>

"Andy G" <aj*****@iastat e.edu> wrote in message
news:er******** ******@tk2msftn gp13.phx.gbl...
> I am getting an error when I try to call my stored procedure. Exception > adding account. Procedure 'stpCFSPH_CM_RG ST_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.Sel ectedItem.Value
>
> Admin.StoreAcco untDetails(txtU serName.Text, passwordHash, salt,
tempAnswer,
> qstn, userRole)
>
> Here is my Admin.StoreAcco untDetails code:
>
> Dim conn As SqlConnection = New SqlConnection(G etConn.GetCnxSt ring()) >
> Dim cmd As SqlCommand = New SqlCommand("stp CFSPH_CM_RGST_U SER", conn) >
> cmd.CommandType = CommandType.Sto redProcedure
>
> Dim sqlParam As SqlParameter = Nothing
>
> [ALL OF THE OTHER PARAMS GO HERE, LEFT OUT FOR CLARITY]
>
> sqlParam = cmd.Parameters. Add("@USER_DESC R", SqlDbType.Int, 10)
>
> sqlParam.Value = userDescr
>
> Try
>
> conn.Open()
>
> cmd.ExecuteNonQ uery()
>
> Catch ex As Exception
>
> ' Code to check for primary key violation (duplicate account name)
>
> ' or other database errors omitted for clarity
>
> Throw New Exception("Exce ption 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
9804
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 in a link. that function can have parameters for URL and window name passed to it. This works peachy in Firefox (1.0). With IE 6 (6.0.29) on two separate computers, I get an "onject expected" error. Going to the MS-based debugger just tells me...
7
9481
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
2888
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 correctly. 3078" after I migrated "MS Access 2000" to "MS SQL Server 2000" and relinked all linked tables. The front-end interface of my application is MS Access 2000. The back-end is MS SQL Server 2000. After I migrated the database and
9
5036
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 www.asp.net and still cannot get past this "error". Can anyone see the error? This <script> example is almost line by line from the Sams ASP.NET Unleashed Book. The error is on line 8. Thanks.
2
6672
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 'method' was expected At the lines:- myCommand.Parameters("@Username").Value = strLogonUsr;
0
1938
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 values of a MouseDown event on the client form. These numbers are supplied by the client. Code snippet: -------------- Client-app: myLabel.Text=srvControl.MouseCoordinates(mouseEv.X,
4
11816
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 its parameters, I get: "Value does not fall within the expected range." How are people interacting with the Crystal Report viewer to set the parameters on a report? I haven't found any useful documentation at
3
2996
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 =0) End sub Please give soln for this error
9
27641
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 patterns(words). What it does is takes a string as a parameter, determines length of string, tests if the length is a perfect square, if it is then it makes a 2-d array with its length and height equal to the lengths root. If it isn't then it cuts it down to...
0
2625
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 multitude of web methods. All the web methods have various parameters, but one parameter which they all have in common is an 'object' parameter. This is due to the fact that the web service works differently according to the type of object being...
0
9569
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10558
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10302
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9130
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2975
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.