473,666 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What does VB/SQL Server want for a parameter name?

Greetings!

I have a SQL Server stored procedure that takes one parameter, named @key.
I am trying to run that stored procedure from a VB app. When I create a
Parameter object and give it the name "key", I get an error message that
says "key is not a parameter for procedure sp_get_active_h oldings". When I
name the parameter "@key", I get a message that says "Procedure
'sp_get_active_ holdings' expects parameter '@key', which was not supplied."

Huh?

It looks like VB is complaining first that "key" is incorrect, and then SQL
is complaining that "@key" is incorrect! What do I have to do? It's a
dinky little stored procedure that could be done just as well in the VB
code, but I'd really like to have all DB-related stuff in the DB.

Here's the procedure:

ALTER PROCEDURE dbo.sp_get_acti ve_holdings (@key INT)
AS
SELECT Name, Symbol, Quantity, Execute_price, IsLong
FROM Holdings
WHERE Covered = 0 AND Portfolio_fk = @key
ORDER BY Symbol;

Here's the VB code:

Public Sub Open(ByVal number As Integer)
m_connection = gDB
Try
If gDB.State = ConnectionState .Closed Then
m_connection.Op en()
End If

dcmdData.Connec tion = gDB
daData.SelectCo mmand = dcmdData
Dim dtData As New dsPortfolio.Por tfolioDataDataT able
daData.Fill(dtD ata)
m_drowData = dtData.Rows(0)
Dim daActiveHolding As New SqlDataAdapter
Dim dcmdActiveHoldi ng As New SqlCommand
Dim pKeyParam As New SqlParameter
Dim pReturnParam As New SqlParameter
pReturnParam.Pa rameterName = "@RETURN_VA LUE"
pReturnParam.Di rection = ParameterDirect ion.ReturnValue
dcmdActiveHoldi ng.Parameters.A dd(pReturnParam )
pKeyParam.Param eterName = "@key"
pKeyParam.SqlDb Type = SqlDbType.Int
pKeyParam.Direc tion = ParameterDirect ion.Input
dcmdActiveHoldi ng.Connection = gDB
dcmdActiveHoldi ng.CommandType = CommandType.Sto redProcedure
dcmdActiveHoldi ng.CommandText = "sp_get_active_ holdings"
dcmdActiveHoldi ng.Connection = m_connection
dcmdActiveHoldi ng.Parameters.A dd(pKeyParam)
daActiveHolding .SelectCommand = dcmdActiveHoldi ng
m_activeHolding s = New dsPortfolio.Act iveHoldingsData Table
daActiveHolding .SelectCommand = dcmdActiveHoldi ng
daActiveHolding .Fill(m_activeH oldings)

Catch e As SqlException
MessageBox.Show ("Error when opening database: " & vbCrLf & _
e.Message)
End Try
End Sub

Thanks very much!

Rob
Nov 21 '05 #1
1 2641
Hi Rob,

It doesn't look like you are assigning the pKeyParam a value. Something
like pKeyParam.Value = 5. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Rob Richardson" <th*****@n2net. net> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Greetings!

I have a SQL Server stored procedure that takes one parameter, named @key.
I am trying to run that stored procedure from a VB app. When I create a
Parameter object and give it the name "key", I get an error message that
says "key is not a parameter for procedure sp_get_active_h oldings". When I name the parameter "@key", I get a message that says "Procedure
'sp_get_active_ holdings' expects parameter '@key', which was not supplied."
Huh?

It looks like VB is complaining first that "key" is incorrect, and then SQL is complaining that "@key" is incorrect! What do I have to do? It's a
dinky little stored procedure that could be done just as well in the VB
code, but I'd really like to have all DB-related stuff in the DB.

Here's the procedure:

ALTER PROCEDURE dbo.sp_get_acti ve_holdings (@key INT)
AS
SELECT Name, Symbol, Quantity, Execute_price, IsLong
FROM Holdings
WHERE Covered = 0 AND Portfolio_fk = @key
ORDER BY Symbol;

Here's the VB code:

Public Sub Open(ByVal number As Integer)
m_connection = gDB
Try
If gDB.State = ConnectionState .Closed Then
m_connection.Op en()
End If

dcmdData.Connec tion = gDB
daData.SelectCo mmand = dcmdData
Dim dtData As New dsPortfolio.Por tfolioDataDataT able
daData.Fill(dtD ata)
m_drowData = dtData.Rows(0)
Dim daActiveHolding As New SqlDataAdapter
Dim dcmdActiveHoldi ng As New SqlCommand
Dim pKeyParam As New SqlParameter
Dim pReturnParam As New SqlParameter
pReturnParam.Pa rameterName = "@RETURN_VA LUE"
pReturnParam.Di rection = ParameterDirect ion.ReturnValue
dcmdActiveHoldi ng.Parameters.A dd(pReturnParam )
pKeyParam.Param eterName = "@key"
pKeyParam.SqlDb Type = SqlDbType.Int
pKeyParam.Direc tion = ParameterDirect ion.Input
dcmdActiveHoldi ng.Connection = gDB
dcmdActiveHoldi ng.CommandType = CommandType.Sto redProcedure
dcmdActiveHoldi ng.CommandText = "sp_get_active_ holdings"
dcmdActiveHoldi ng.Connection = m_connection
dcmdActiveHoldi ng.Parameters.A dd(pKeyParam)
daActiveHolding .SelectCommand = dcmdActiveHoldi ng
m_activeHolding s = New dsPortfolio.Act iveHoldingsData Table
daActiveHolding .SelectCommand = dcmdActiveHoldi ng
daActiveHolding .Fill(m_activeH oldings)

Catch e As SqlException
MessageBox.Show ("Error when opening database: " & vbCrLf & _
e.Message)
End Try
End Sub

Thanks very much!

Rob

Nov 21 '05 #2

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

Similar topics

26
3482
by: Steven Bethard | last post by:
I thought it might be useful to put the recent lambda threads into perspective a bit. I was wondering what lambda gets used for in "real" code, so I grepped my Python Lib directory. Here are some of the ones I looked, classified by how I would rewrite them (if I could): * Rewritable as def statements (<name> = lambda <args>: <expr> usage) These are lambdas used when a lambda wasn't needed -- an anonymous function was created with...
0
3673
by: Monica Ferrero | last post by:
Hi! I'm not sure if this is the most adequate mySQL list for this post. If not, please indicat me which one I should use... I'm using Tomcat 4.1.24 with Apache 2 and MySQL 4.0.13. I have the mysql- connector-java-2.0.14-bin.jar in commons/lib. The application runs normally, and usually about once or twice a day I get this exception org.apache.commons.dbcp.DbcpException: java.sql.SQLException: Server configuration denies access to data...
8
2685
by: DanB | last post by:
This is probably soooo simple but I can't seem to get it. I have a text file that I want users to download via a web page. I want the file to be saved to a default folder (or one that they choose) on the users / client file system. I have toyed with a Self-Extracting zip file but the contents of my zip file changes each time it is downloaded so that invalidates the exe file. Also the text file is so small it is a waste to zip it.
4
2996
by: nicholas | last post by:
Weird thing: Got an aspx page with a button and an associated code in VB.net. On my testing server the page works fine. On the old hosters server the page worked fine too. But now, at the new hoster it does not. When I click on the submit button: nothing happens. The only thing that works is form validation.
5
1798
by: Amelyan | last post by:
I am struggling here trying to determine what is a good programming practice as far as referencing your URLs. When you use Response.Redirect, do you use 1) Hard-coded string -- Response.Redirect("MyPage.aspx"); 2) Constants -- Response.Redirect(STRMyPage); // where input parameter is -> const string STRMyPage = "MyPage.aspx"; 3) Something entirely differnent?
3
2213
by: Jordan | last post by:
I am dynamically inserting an html <input> tag as text (equivalent of an image button) into a page via a Literal control. Something like this gets inserted: <input type="image" name="MyImageButton" id="MyImageButton" src="somePic.jpg" /> I want for the code-behind to "know" when the user clicked on the image - but I don't want to also have to dynamically specify a delegate for an event procedure to handle this control which is really...
7
1920
by: ÀÏÆÅ»³ÔÐ5¸öÔ | last post by:
I want use dropdownlist contral in gridview but have trouble now mycode here: i'm very sorry for my poor english <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
11
4329
by: pamelafluente | last post by:
Hi I am executing some simple sample code: Using OleDbCommand As New OleDbCommand(Me.DBQuery.Text, Me.OleDbConnection) Dim OleDbParameter As OleDbParameter = OleDbCommand.Parameters.Add("@Pinco", OleDbType.VarWChar) OleDbParameter.Direction = ParameterDirection.Input OleDbParameter.Value = "Berlin"
0
2658
by: Steve | last post by:
I have a gridview which uses an objectdatasource for its select and delete. The delete command uses the function below. The delete itself works but the extra logic which requires parameters AccountDebitID and AccountCreditID does not work. 'Delete a transaction Sub deletetrans(ByVal transactionid As Integer, ByVal transactionamount
0
8440
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
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
8638
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7381
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
6191
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
5662
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();...
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1769
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.