| Author: Praveen 04 Sep 2008 | Member Level: Diamond | Rating:   Points: 3 |
SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand.CommandType = CommandType.StoredProcedure; SqlParameter name; name = da.SelectCommand.Parameters.Add("@name", SqlDbType.VarChar, 50); name.Value = txtName.Text; SqlParameter address; address = da.SelectCommand.Parameters.Add("@address", SqlDbType.VarChar, 100); address.Value = txtAdress.Text; da.SelectCommand.Connection = con; da.SelectCommand.CommandText = "sp_getAdress"; DataSet ds = new DataSet(); da.Fill(ds)
|
| Author: Bunty 04 Sep 2008 | Member Level: Diamond | Rating:   Points: 3 |
Hi,
This code sample shows how to call a stored procedure which returns a value from VB.NET.
Create procedure prc_getBal(@cid int,@bal money output) As Begin Select @bal=bal from customers where cid=@cid End
Code in VB.NET
Imports System.Data.SQLClient
public Class Form Dim con as SQLConnection Dim cmd as SQLCommand
Under FindBalance Button:
Dim cid as integer=InputBox("Enter Cid") con=new SQLConnection("user id=sa;password=123;database=") cmd=new SQLCommand("prc_getBal") cmd.CommandType=CommandType.StoredProcedure cmd.Parameters.AddWithValue("@cid",cid) cmd.Parameters.AddWithValue("@bal",SQLDbType.Money).Direction=ParameterDirection.Output con.open() cmd.ExecuteNonQuery() MessageBox.Show(cmd.Parameters("@bal").Value) con.Close()
Thanks and Regards S.S.Bajoria
Thanks & Regards S.S.Bajoria
|