C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Stored Procedure


Posted Date: 03 Sep 2008    Resource Type: Code Snippets    Category: ADO.NET

Posted By: Bunty       Member Level: Diamond
Rating:     Points: 10



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()




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Calling Stored Procedure from a .NET Application.  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Bulk Copy - Using Transcation - Moving Data From One Server to Another Server (Central)
Previous Resource: Common database class for .Net application (VB.Net)
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing service

Contact Us    Privacy Policy    Terms Of Use