In Vb.net How to call simple sp and pass input parameters and get output parameter ? [Resolved]

Posted by Nav234 under VB.NET on 7/19/2010 | Views : 3488 | Status : [Member] | Replies : 2
Hi all ,

Im using sql server 2005 and vs 2008.

Correct if my syntax are wrong,
I have created a sp with two i/p values and two o/p values like,
create procedure dbo.employee
(@emp_id int,
@emp_name varchar(50),
@group_name OUTPUT,
@department_id OUTPUT
)

Here my SP name (employee) and Parameters (emp_id input
emp_name input
group_name OUTPUT,department_id OUTPUT,
)
two input and two ouptut param ,IS IT POSSIBLE ???

IF NOT ,explain me to call this SP from VB.net with single output
can any1 help on this issue ?

Thanks in advance

S.Naveen...


Responses

Posted by: Neeks on: 7/19/2010 [Member] Bronze | Points: 50

Up
0
Down

Resolved
You can take the reference of following code.
Dim myConnection As New SqlConnection(SqlHelper.ConnectionString)

Dim myCommand As New SqlCommand("chkEmail", myConnection)

myCommand.CommandType = CommandType.StoredProcedure

Dim parameterEmail As New SqlParameter("@Email", SqlDbType.VarChar, 50)
parameterEmail.Value = Email
myCommand.Parameters.Add(parameterEmail)

Dim parameterCount As New SqlParameter("@Count", SqlDbType.Int, 4)
parameterCount.Direction = ParameterDirection.Output
myCommand.Parameters.Add(parameterCount)

myConnection.Open()
myCommand.ExecuteNonQuery()
myConnection.Close()

Return parameterCount.Value.ToString()


Nav234, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nav234 on: 9/18/2010 [Member] Starter | Points: 25

Up
0
Down
Can you explain in C# if possible...

S.Naveen...

Nav234, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response