Pass Parameter to Stored Proc

hopmedic

New member
Joined
Feb 22, 2006
Messages
2
Programming Experience
Beginner
I have a datagrid control on my form, and after binding it to a dataset using the gui, the necessary tableadapter, dataset, and bindingsource controls are present in the designer view.

The controls are bound to a stored procedure that requires a date parameter to be passed, which I would like to do with a datetimepicker, and would like to fire a subprocess that updates the datagrid using the valuechanged event of the datetimepicker.

The problem is that I cannot find how to update the datagrid by running the stored proc programmatically using the bound controls. I have done this before using programming in the background, but I cannot figure out how to pass the parameter using the bound controls - therefore my datagridview never populates.

I could do this programmatically if I had to, but it's so easy to format the columns the way I want to using the gui and binding the controls, and I just cannot imagine that Microsoft would give me all these hi-tech fancy tools and not have a way to pass the parameter I need to.

Also, another bit of the puzzle that I've not figured out yet, is how to use yet a different stored proc to update the tables that will need to be updated from this datagridview - again, I'd hope to be able to do it using the bound controls, but we'll see...

Thanks,

Rich
 
Ummmm... Cursor?? Don't know the answer to that one, but it boils down to a select statement with a couple of where's in it so it needs the parameter from the datetimepicker.
 
okay, so your sproc, as its last line, does a SELECT? Then it returns a cursor.. SQLServer probably hides that technicality..

OK so to update the data value of the date:

Bind the .Value of the date time picker, to the date of the bindingsource (which is bound to the datatable)

Whichever row the Bindingsource is Currently pointing to, will have its date updated. The grid will update its display accordingly.

If you mean that the grid has to show all records from a certain day, then call this:

VB.NET:
'in valuechanged event
necessaryTableAdapter.Fill(necessaryDataSet.necessaryDataTable, dateTimePicker1.Value)


How to use another sproc to update the data in the db? SImply go to the TableAdapter for this Datatable in the dataset, Click the heading XXXTableAdapter, and change the Update COmmand to be using a stored procedure.. ensure the columns are mapped to the parameters by going into the Parameters prop and checking the SourceCOlumn property for each param, is whatever it ought to be in the datatable...
 
Back
Top