Solved

Passing parameter to Stored Procedure

Posted on 2011-09-14
3
269 Views
Last Modified: 2012-06-22
I have the following stored procedure.  I want to pass HTCode from my VB.Net subroutine and then received the values back in a datatable.  Is that possible?  If so, could someone help me out with the code?
ALTER PROCEDURE dbo.HospBillingCodeLoop
	(
	@HTCode varchar(50)
	)
AS
	SELECT * FROM [Hospital Billing Data SQL] WHERE HTCode = @HTCode 
	RETURN

Open in new window

0
Comment
Question by:kshumway
3 Comments
 
LVL 39

Accepted Solution

by:
appari earned 500 total points
ID: 36540216
try something like this

dim sqlConnect as New System.Data.SqlClient.SqlConnection("connectionString")
sqlConnect.Open()

using ds as new dataset
	using sqlCmd as new SQLCommand()
		sqlCmd.connection = sqlConnect
		sqlCmd.CommandText = "HospBillingCodeLoop"
		sqlCmd.parameters.addwithvalue("@HTCode ","HTCode Value ")
		sqlCommand.CommandType = CommandType.StoredProcedure 
		dim sqlDataAdapter as New System.Data.SqlClient.SqlDataAdapter(sqlCommand)
		sqlDataAdapter.Fill(dataSet)
	end using 
end using 

Open in new window


after the fill satement you will have the returned data in the dataset.
for more info search in books online for keywords like sqldataadapter, dataset, sqlcommand.
for a start http://msdn.microsoft.com/en-us/library/yy6y35y8(VS.80).aspx
0
 
LVL 51

Expert Comment

by:HainKurt
ID: 36540228
something like this:

con.ConnectionString = Settings.ConnectionString("myDB");
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "HospBillingCodeLoop"
cmd.Parameters.Add("@HTCode ", SqlDbType.Int).Value = HTCode;
DataReader dr = cmd.ExecuteReader();
DataSet ds = new Dataset();
ds.Load(dr);
...
0
 

Author Closing Comment

by:kshumway
ID: 36540286
Thank you!  It worked perfectly.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Asp/Net Validation date Issue 9 38
Converting C# Objects into JSON file 7 39
Hide Tab Page 3 19
Create XML 5 33
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now