473,405 Members | 2,261 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,405 software developers and data experts.

Unable to recognize stored procedure param

Hello,

I am attempting to create a small app that executes a stored procedure
in SQLServer and have been unsuccessful in getting the procedure to
execute from my application. The error received when issuing the
ExecuteNonQuery is "Procedure 'TestProc' expects parameter '@IN', which
was not supplied.".

Any help would be greatly appreciated. Below is a test stored proc and
code.

Thanks,
Virgil

----------------------------------------------------------------------------------------------

create procedure TestProc
(@IN int
,@OUT int OUTPUT
)
as

set @OUT = 10
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim ConnString As String = "**************" '<-- not displayed
Dim Connection As SqlConnection
Dim Command As SqlCommand
Dim InParam As SqlParameter
Dim OutParam As SqlParameter

Try

' Create connection
Connection = New SqlConnection(ConnString)
Connection.Open()

' Create Command
Command = New SqlCommand("TestProc", Connection)
Command.CommandType = CommandType.StoredProcedure

' Create parameters
InParam = New SqlParameter("@IN", SqlDbType.Int)
InParam.Direction = ParameterDirection.Input
'Command.Parameters.AddWithValue("@IN", 1)

OutParam = New SqlParameter("@OUT", SqlDbType.Int)
OutParam.Direction = ParameterDirection.Output

' Add the parameters to the command
Command.Parameters.Add(InParam)
Command.Parameters.Add(OutParam)

' Execute the command
Command.ExecuteNonQuery()

' Show results
MessageBox.Show(Command.Parameters(1).Value)

Catch ex As Exception

MessageBox.Show(ex.Message)

Finally
If (Connection Is Nothing) = False Then
If Connection.State = ConnectionState.Open Then
Connection.Close()
End If
End If
End Try

End Sub

Mar 2 '06 #1
2 1006
> Hello,

I am attempting to create a small app that executes a stored procedure
in SQLServer and have been unsuccessful in getting the procedure to
execute from my application. The error received when issuing the
ExecuteNonQuery is "Procedure 'TestProc' expects parameter '@IN',
which was not supplied.". ' Create parameters
InParam = New SqlParameter("@IN", SqlDbType.Int)
InParam.Direction = ParameterDirection.Input
'Command.Parameters.AddWithValue("@IN", 1)
' Add the parameters to the command
Command.Parameters.Add(InParam)


You neglected to set the value property of InParam.

Jim Wooley
Mar 2 '06 #2
Doh! I was thinking that the error message was tellnig me it could not
find the param.

Thanks a bunch!

Mar 3 '06 #3

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

Similar topics

6
by: dw | last post by:
Hello all, I'm having a dickens of a time calling a stored procedure on a connection. Every time I do, it generates an error "Arguments are of the wrong type, are out of acceptable range, or are in...
1
by: Bari Allen | last post by:
I have a Stored procedure in SQL, that works, when tested in SQL, with one input & several output parameters, as follows: CREATE PROCEDURE myProcedure @MyID int , @First varchar(80) OUTPUT ,...
4
by: stjulian | last post by:
I have a stored procedure that is supposed to 1. Increment a counter in Table A via a transaction 2. Use this value as the primary key to add in an address to customers Table B (Referenced as a...
5
by: Eugene Anthony | last post by:
I have created the following stored procedure whereby it will check whether the categoryID is valid and if it is then the updation will be performed, else a -1 will be returned. This procedure will...
1
by: Jay | last post by:
I hope this is the correct place to post this. I'm using a stored procedure to simply look up and return a value from a database. The db key is an integer, everything else is varchar. The stored...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
2
by: Bari Allen | last post by:
ASP Classic question: I have a Stored procedure in SQL, that works, when tested in SQL, with one input & several output parameters, as follows: CREATE PROCEDURE myProcedure @MyID int , @First...
2
by: Thomas Beyerlein | last post by:
I am building a UI, I am using stored procedures for executing SQL commands on the server. When I ran a insert stored procedure it returned me a error message that it could not find a parameter...
2
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
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...

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.