473,385 Members | 1,944 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,385 software developers and data experts.

regatding stroed procedure in asp.net

Hi
i've created stored procedure in

sql server 2000 which returns a value

see the stroed procedure
CREATE PROCEDURE QA_Select_AdminOrRec
@Role varchar(50),
@username varchar(50),
@pwd varchar(50)

AS

if exists (select * from

QA_Admin_Recruiter where role = @role

and username=@username and pwd=@pwd)
return (1)
else
return (0)
GO

and in asp.net i called this stroed

procedure like this

Dim username As New OleDbParameter
username.OleDbType = OleDbType.VarChar
username.Value = txtUserName.Text

Dim pwd As New OleDbParameter
pwd.OleDbType = OleDbType.VarChar
pwd.Value = txtPassword.Text

Dim role As New OleDbParameter
role.OleDbType = OleDbType.VarChar
role.Value = Session("user")

cmd.CommandText = "QA_Select_AdminOrRec"

cmd.Parameters.Add(role)
cmd.Parameters.Add(username)
cmd.Parameters.Add(pwd)

cmd.ExecuteNonQuery().

here i've to check the value returned by stored procedure.

can anyone tell me how to write code to capture a value which returned by
the stroed procedure.

thanx in advance
yoshitha.
Nov 19 '05 #1
4 1363
Hi,

First, create a parameter "ReturnValue", set its Direction property to
ReturnValue, add it to the parameters collection (as you are using OleDb
provider, this is going to be your first parameter), then get the value from
the SP after executing ExecuteNonQuery as follows: -

Dim RetVal as Integer

Retval = CType(Cmd.Parameters("ReturnValue").Value, Integer)

HTH

Regards
Joyjit

"Yoshitha" <gu**********@rediffmail.com> wrote in message
news:uT*************@TK2MSFTNGP14.phx.gbl...
Hi
i've created stored procedure in

sql server 2000 which returns a value

see the stroed procedure
CREATE PROCEDURE QA_Select_AdminOrRec
@Role varchar(50),
@username varchar(50),
@pwd varchar(50)

AS

if exists (select * from

QA_Admin_Recruiter where role = @role

and username=@username and pwd=@pwd)
return (1)
else
return (0)
GO

and in asp.net i called this stroed

procedure like this

Dim username As New OleDbParameter
username.OleDbType = OleDbType.VarChar
username.Value = txtUserName.Text

Dim pwd As New OleDbParameter
pwd.OleDbType = OleDbType.VarChar
pwd.Value = txtPassword.Text

Dim role As New OleDbParameter
role.OleDbType = OleDbType.VarChar
role.Value = Session("user")

cmd.CommandText = "QA_Select_AdminOrRec"

cmd.Parameters.Add(role)
cmd.Parameters.Add(username)
cmd.Parameters.Add(pwd)

cmd.ExecuteNonQuery().

here i've to check the value returned by stored procedure.

can anyone tell me how to write code to capture a value which returned by
the stroed procedure.

thanx in advance
yoshitha.

Nov 19 '05 #2
hi

now i've included the statements what u have said in ur reply

see this

Dim retvalue As New OleDbParameter

retvalue.OleDbType = OleDbType.Integer

retvalue.Direction = ParameterDirection.ReturnValue

cmd.Parameters.Add(retvalue)

cmd.Parameters.Add(role)

cmd.Parameters.Add(username)

cmd.Parameters.Add(pwd)

cmd.ExecuteNonQuery()

res = CType(cmd.Parameters("retvalue").Value(), Integer)

after executing am getting error at lst line of code which is displayed
above. the error i got is below.

An OleDbParameter with ParameterName 'retvalue' is not contained by this
OleDbParameterCollection.


Nov 19 '05 #3
Hi,

In your SP, add the parameter, and instead of returning 1 or 0, write
Set Retvalue = 1
else
Set Retvalue = 0

@@Return Retvalue

HTH

Joyjit
"Yoshitha" <gu**********@rediffmail.com> wrote in message
news:On**************@TK2MSFTNGP12.phx.gbl...
hi

now i've included the statements what u have said in ur reply

see this

Dim retvalue As New OleDbParameter

retvalue.OleDbType = OleDbType.Integer

retvalue.Direction = ParameterDirection.ReturnValue

cmd.Parameters.Add(retvalue)

cmd.Parameters.Add(role)

cmd.Parameters.Add(username)

cmd.Parameters.Add(pwd)

cmd.ExecuteNonQuery()

res = CType(cmd.Parameters("retvalue").Value(), Integer)

after executing am getting error at lst line of code which is displayed
above. the error i got is below.

An OleDbParameter with ParameterName 'retvalue' is not contained by this
OleDbParameterCollection.

Nov 19 '05 #4
Yoshitha wrote:
hi

now i've included the statements what u have said in ur reply

see this

Dim retvalue As New OleDbParameter

retvalue.OleDbType = OleDbType.Integer

retvalue.Direction = ParameterDirection.ReturnValue

cmd.Parameters.Add(retvalue)

cmd.Parameters.Add(role)

cmd.Parameters.Add(username)

cmd.Parameters.Add(pwd)

cmd.ExecuteNonQuery()

res = CType(cmd.Parameters("retvalue").Value(), Integer)

after executing am getting error at lst line of code which is displayed
above. the error i got is below.

An OleDbParameter with ParameterName 'retvalue' is not contained by this
OleDbParameterCollection.


try this to get the value after the ExecuteNonQuery:
res = CType(retvalue.Value, Integer)

or set the name of the parameter before ExecuteNonQuery:
retvalue.ParameterName = "retvalue"
The problem is that you create a parameter with no name (and assign
it to the retvalue variable) and later you are trying to retrieve
that same parameter by name. There is no automatic link between
the variable named "retvalue" and some parameter with ParameterName
"retvalue"!
--
Hans Kesting
Nov 19 '05 #5

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

Similar topics

2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
1
by: Yoshitha | last post by:
Hi i've created stored procedure in sql server 2000 which returns a value see the stroed procedure CREATE PROCEDURE QA_Select_AdminOrRec @Role varchar(50),
2
by: Yoshitha | last post by:
hi all i created a stored procedure like this which retruns values am not sure whether it is correct or not. if it is wrong can you tell me where i did mistake. CREATE PROCEDURE...
1
by: bbawa1 | last post by:
I have a stored proceure whic is returning a table. Now I need ADO.Net statement So that I can pass parameters to this stored procedure and get Retuened table from stored procedure. Could you...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...

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.