Question Passing parameters into an SQL Query

NiXi

New member
Joined
Jan 24, 2011
Messages
2
Programming Experience
1-3
I have a database setup and connected as a datasource for use in a simple shop system.

The way that i have it is that when the form loads it loads the stock levels of each item into variables, then when an order has been filled update said variables.

Then on exiting the form i want it to update the database with the new stock level variables from the form, and this is where the problem lays.

I'm calling the query like so:
VB.NET:
QueryCall.Stock_1_Stock_Updater()

where "QueryCall" is defined as a "DataSetTableAdapters.QueriesTableAdapter"

The problem is I have no clue as to how to pass parameter values into the query to update each stock item.

the SQL code for the query is as follows:
VB.NET:
UPDATE    Stock
SET              Stock.Stock = ?
WHERE     (ID = 1)

(Yes the table is called stock, and so is the column heading, terrible idea)

So the question comes down to this: How do I structure the query to update from a parameter, and how would said parameter be passed?

Thanks in advance
 
It seems to me that you're going about this the wrong way. If you want the stock levels of each item then get them all with a single query to populate a single DataTable. You can then get the stock levels from that table by item ID, product code or whatever. Any adjustements you need to make, you make to the data in that DataTable. When you're done, you save the whole DataTable back to the database with a single Update call.
 
@jmcilhinney

That does sound like a much better way of doing it, but how would i go about implementing it?
I understand enough about datasets to load one into a datagrid object, but not much beyond that.
 
Back
Top