473,657 Members | 2,409 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 1537
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
6693
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
3185
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
5450
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
0
2642
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
3451
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
5152
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
4136
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
4100
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
3177
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
8395
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
8310
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
8826
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...
0
8732
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
8503
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,...
1
6166
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
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
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.