?
Solved

Passing parameter to Stored Procedure

Posted on 2011-09-14
3
Medium Priority
?
309 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 2000 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 57

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

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

771 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