Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.67/5 (3 votes)
See more:
Hello,
"strongly typed DataSet" is using a stored procedure that has a parameter, how do i pass parameter value to it at run time.
thanks
Posted
Updated 23-Jul-12 8:18am
v2
Comments
Sandeep Mewara 23-Jul-12 14:20pm    
Elaborate.

Same as you do for any SQL query. For example, http://msdn.microsoft.com/en-us/library/yy6y35y8(v=vs.71).aspx[^]
 
Share this answer
 
The tableadapter using the stored procedure with the parameter will have methods with additional parameters. Visual Studio will create them automatically when using stored procedures in strongly typed datasets.

For example when you use the stored procedure to return a table of person records selected by age (your stored procedure has 2 parameters MinimumAge and MaximumAge). The generated Fill and GetData methods will have 2 (additional) parameters: MinimumAge as Int32, MaximumAge as Int32. You could call them with the following code:

VB
Dim table as MyDataSet.PersonTable
Dim minimumAge as Int32 = 24
Dim maximumAge as Int32 = 40

Using ta as MyDataSetTableAdapters.PersonTableAdapter = _ 
     new MyDataSetTableAdapters.PersonTableAdapter()
  table = ta.GetData(minimumAge, maximumAge)
End Usingl


The same principle will be used when your stored procedure only returns a scalar value or no value at all. For instance when your stored procedure returns the number of persons within a age range, if will generated a method in de QueriesTableAdapter.

VB
Dim minimumAge as Int32 = 24
Dim maximumAge as Int32 = 40
Dim numberOfPersonWithinRage as Int32

Using ta as MyDataSetTableAdapters.QueriesTableAdapter = _ 
     new MyDataSetTableAdapters.QueriesTableAdapter()
  numberOfPersonWithinRange = ta.CountPersonsByAge(minimumAge, maximumAge)
End Using


When you use SQL statements with parameters in your strong typed datasets, the same logic will apply.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900