Solved

Passing parameter to Stored Procedure

Posted on 2011-09-14
3
304 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 55

Expert Comment

by:Huseyin KAHRAMAN
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 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