473,888 Members | 1,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stored procedure parameter prob

Hi,

This is my stored procured. i try to pass the parametre like this. i am
getting error.
any one please tell me how to pass the parameter?

vb code:
..Connection = New OleDbConnection (strConn)
..Connection.Op en()
..CommandText = "sp_RegShow 1"
..Parameters.It em(1).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
..Parameters.It em(2).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
thanks
bala

Stored procedure:

CREATE PROCEDURE [dbo].[sp_RegShow1]
(@FirstName_1 [nvarchar](50),
@LastName_1 [nvarchar](50)
)
AS
select * from tbleusers where firstname=@Firs tName_1 and lastname=@LastN ame_1
GO

Nov 21 '05 #1
6 1544
Hi,

Try this.

..Parameters.Ad d("@FirstName", Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~"))
..Parameters.Ad d("@LastName" , Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~"))
Ken
------------------

"Bala" <Ba**@discussio ns.microsoft.co m> wrote in message
news:EE******** *************** ***********@mic rosoft.com...
Hi,

This is my stored procured. i try to pass the parametre like this. i am
getting error.
any one please tell me how to pass the parameter?

vb code:
..Connection = New OleDbConnection (strConn)
..Connection.Op en()
..CommandText = "sp_RegShow 1"
..Parameters.It em(1).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
..Parameters.It em(2).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
thanks
bala

Stored procedure:

CREATE PROCEDURE [dbo].[sp_RegShow1]
(@FirstName_1 [nvarchar](50),
@LastName_1 [nvarchar](50)
)
AS
select * from tbleusers where firstname=@Firs tName_1 and
lastname=@LastN ame_1
GO
Nov 21 '05 #2
Hi,

Thanks for the reply.

i tried like this but still i am getting error.
err msg:
procedure sp_regshow1 'expects parameter '@Firstname_1 which is not supplied.

..Parameters.Ad d("@FirstName_1 ", Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~"))
.Parameters.Add ("@LastName_ 2", Replace(Trim(Mi d(cboCustName.T ext,
InStr(cboCustNa me.Text, "-") + 2)), "'", "~"))

thanks
bala

"Ken Tucker [MVP]" wrote:
Hi,

Try this.

..Parameters.Ad d("@FirstName", Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~"))
..Parameters.Ad d("@LastName" , Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~"))
Ken
------------------

"Bala" <Ba**@discussio ns.microsoft.co m> wrote in message
news:EE******** *************** ***********@mic rosoft.com...
Hi,

This is my stored procured. i try to pass the parametre like this. i am
getting error.
any one please tell me how to pass the parameter?

vb code:
..Connection = New OleDbConnection (strConn)
..Connection.Op en()
..CommandText = "sp_RegShow 1"
..Parameters.It em(1).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
..Parameters.It em(2).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
thanks
bala

Stored procedure:

CREATE PROCEDURE [dbo].[sp_RegShow1]
(@FirstName_1 [nvarchar](50),
@LastName_1 [nvarchar](50)
)
AS
select * from tbleusers where firstname=@Firs tName_1 and
lastname=@LastN ame_1
GO

Nov 21 '05 #3
Bala,

Do you add the parameters in the same sequence as in the SQL string.
That is a difference between OleDb and SQLClient.

I hope this helps?

Cor

"Bala"
Hi,

Thanks for the reply.

i tried like this but still i am getting error.
err msg:
procedure sp_regshow1 'expects parameter '@Firstname_1 which is not
supplied.

.Parameters.Add ("@FirstName_1" , Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~"))
.Parameters.Add ("@LastName_ 2", Replace(Trim(Mi d(cboCustName.T ext,
InStr(cboCustNa me.Text, "-") + 2)), "'", "~"))

thanks
bala

"Ken Tucker [MVP]" wrote:
Hi,

Try this.

..Parameters.Ad d("@FirstName", Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~"))
..Parameters.Ad d("@LastName" , Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~"))
Ken
------------------

"Bala" <Ba**@discussio ns.microsoft.co m> wrote in message
news:EE******** *************** ***********@mic rosoft.com...
Hi,

This is my stored procured. i try to pass the parametre like this. i am
getting error.
any one please tell me how to pass the parameter?

vb code:
..Connection = New OleDbConnection (strConn)
..Connection.Op en()
..CommandText = "sp_RegShow 1"
..Parameters.It em(1).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
..Parameters.It em(2).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
thanks
bala

Stored procedure:

CREATE PROCEDURE [dbo].[sp_RegShow1]
(@FirstName_1 [nvarchar](50),
@LastName_1 [nvarchar](50)
)
AS
select * from tbleusers where firstname=@Firs tName_1 and
lastname=@LastN ame_1
GO

Nov 21 '05 #4
"Bala" <Ba**@discussio ns.microsoft.co m> wrote in message
news:EE******** *************** ***********@mic rosoft.com...
Hi,

This is my stored procured. i try to pass the parametre like this. i am
getting error.
any one please tell me how to pass the parameter?

vb code:
.Connection = New OleDbConnection (strConn)
.Connection.Ope n()
.CommandText = "sp_RegShow 1"
.Parameters.Ite m(1).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
.Parameters.Ite m(2).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
thanks
bala

Stored procedure:

CREATE PROCEDURE [dbo].[sp_RegShow1]
(@FirstName_1 [nvarchar](50),
@LastName_1 [nvarchar](50)
)
AS
select * from tbleusers where firstname=@Firs tName_1 and
lastname=@LastN ame_1
GO


I think it should be:

.Parameters.Ite m(0).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
.Parameters.Ite m(1).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
Nov 21 '05 #5
Hi Harry,

i tried your way.but i got this error.

Invalid index 0 for this oledbparameterC ollection with count=0
any idea?

thanks
bala
"Harry Strybos" wrote:
"Bala" <Ba**@discussio ns.microsoft.co m> wrote in message
news:EE******** *************** ***********@mic rosoft.com...
Hi,

This is my stored procured. i try to pass the parametre like this. i am
getting error.
any one please tell me how to pass the parameter?

vb code:
.Connection = New OleDbConnection (strConn)
.Connection.Ope n()
.CommandText = "sp_RegShow 1"
.Parameters.Ite m(1).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
.Parameters.Ite m(2).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
thanks
bala

Stored procedure:

CREATE PROCEDURE [dbo].[sp_RegShow1]
(@FirstName_1 [nvarchar](50),
@LastName_1 [nvarchar](50)
)
AS
select * from tbleusers where firstname=@Firs tName_1 and
lastname=@LastN ame_1
GO


I think it should be:

.Parameters.Ite m(0).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
.Parameters.Ite m(1).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")

Nov 21 '05 #6
Don't forget to set the CommandType!

..CommandText = "sp_RegShow 1"
..CommandType = CommandType.Sto redProcedure

I also do not see where you are adding Parameters to the command object.

..Parameters.Ad d(New OleDBParameter( "@FirstName _1",
Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~"))

Not to nitpick, but do not prefix your proc names with sp_ or xp_, it forces
SQL Server to look in the Master DB first, then the default DB for that
connection.
"Bala" <Ba**@discussio ns.microsoft.co m> wrote in message
news:BC******** *************** ***********@mic rosoft.com...
Hi Harry,

i tried your way.but i got this error.

Invalid index 0 for this oledbparameterC ollection with count=0
any idea?

thanks
bala
"Harry Strybos" wrote:
"Bala" <Ba**@discussio ns.microsoft.co m> wrote in message
news:EE******** *************** ***********@mic rosoft.com...
> Hi,
>
> This is my stored procured. i try to pass the parametre like this. i am
> getting error.
> any one please tell me how to pass the parameter?
>
> vb code:
> .Connection = New OleDbConnection (strConn)
> .Connection.Ope n()
> .CommandText = "sp_RegShow 1"
> .Parameters.Ite m(1).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
> InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
> .Parameters.Ite m(2).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
> InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
>
>
> thanks
> bala
>
> Stored procedure:
>
> CREATE PROCEDURE [dbo].[sp_RegShow1]
> (@FirstName_1 [nvarchar](50),
> @LastName_1 [nvarchar](50)
> )
> AS
> select * from tbleusers where firstname=@Firs tName_1 and
> lastname=@LastN ame_1
> GO
>


I think it should be:

.Parameters.Ite m(0).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")
.Parameters.Ite m(1).Value = Replace(Trim(Mi d(cboCustName.T ext, 1,
InStr(cboCustNa me.Text, "-") - 1)), "'", "~")

Nov 21 '05 #7

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

Similar topics

0
6711
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
4
3199
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the Throwable as an OUT parameter and what datatype should I use in the CREATE PROCEDURE and DROP PROCEDURE statements? Here's what I tried: - the method signature for the stored procedure included: Throwable throwable
2
5470
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
0
2661
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how to call them from an ASP.Net page Every modern database system has a stored procedure language. SQL Server is no different and has a relatively sophisticated and easy to use system. This article will not attempt to go into depth in explaining...
7
3475
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function 'UpdateRegistrant' expects parameter '@EMail', which was not supplied. The field value was null in the database and not changed in the FormView so is null going back into the stored procedure. I'm stumped and would greatly appreciate any suggestions.
3
5167
by: mahajanvit | last post by:
Hi one and all I got this problem during my project. So in order to solve this I made a very small application. I am trying to insert using SP and sqldatasource control. I know that while using sqldatasource control, there is no need of opening and closing a connection. Also there is no need to write connection string. When i am selecting table from sqldatasource and writing insert statement in C# code, its working fine. When I am...
9
4150
by: fniles | last post by:
I am using VB.NET 2003 and SQL2000 database. I have a stored procedure called "INSERT_INTO_MYTABLE" that accepts 1 parameter (varchar(10)) and returns the identity column value from that table. When calling the stored procedure from VB.NET, in the CommandText, can I just say "INSERT_INTO_MYTABLE '12345'" instead of calling it with "INSERT_INTO_MYTABLE" then do the following : OleDbCommand2.Parameters.Add("@Account", SqlDbType.VarChar, 10)...
2
4114
by: jed | last post by:
I have created this example in sqlexpress ALTER PROCEDURE . @annualtax FLOAT AS BEGIN SELECT begin1,end1,deductedamount,pecentageextra FROM tax
0
3199
by: SOI_0152 | last post by:
Hi all! Happy New Year 2008. Il hope it will bring you love and happyness I'm new on this forum. I wrote a stored procedure on mainframe using DB2 7.1.1 and IBM language c. Everything works fine. Now we decided to move from mainframe IMS-DB2 to Windows 2003 server-DB2 UDB for LUW 9.5.
0
9961
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...
1
10886
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
9597
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
7990
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
7148
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
5819
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...
0
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4642
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
3
3252
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.