Solved

Passing parameter to Stored Procedure

Posted on 2011-09-14
3
301 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 52

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

Industry Leaders: 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

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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