DataTables Question

DavieBoy2

New member
Joined
Mar 30, 2010
Messages
2
Programming Experience
5-10
Hi

I've started working on an application that is not class based and making it class based at this stage in development would be too much work. The good thing about classes is that you can get all the details for a single row from a particular table (e.g. SELECT * FROM CLIENT WHERE CLIENTID = @CLIENTiD). Then you can get any value of the class by doing something like me.txtName.text = ClassClient.FullName

Anyway if you can imagine our client table has about 30 fields in it. So we could technically have 30 different functions (where each function calls the same stored procedure e.g. SELECT * FROM CLIENT WHERE CLIENTID = @CLIENTiD), but each function returns one single column from the stored procedure.

Basically what I want is just one function that connects to the one stored procedure and it would be possible to get any one of the 30 columns (well the data for one row) out of the function. I thought perhaps a DataTable would be the best bet, which would return just one row, then I could say something like DataTable.ClientName or DataTable.ClientAddressLine1 etc etc.

Could anyone help with this. Or perhaps there's a better way of doing it. It would be good if you could show me how to do this with a stored procedure as I've really done very little with DataTables/TableAdaptors.

Many thanks in advance.
Dave :)
 
See the DW2 links in my sig, start with Creating a Simple Data Application.. then read the sections on how to use stored procedures to read/write databases
 
Hi

Managed to find the section on 'Creating a Simple Data Application', but couldn't find the section on 'how to use stored procedures to read/write databases'.

But I'm sure I can work it out from there.

Many thanks,
Dave :)
 
Seems theyve jigged stuff around a bit.. Im sure there used to be sections on stored procedures

When youre adding your tableadapter (right click the dataset, choose add new tableadapter), youre given the option to use an existing/new stored procedure instead of a select statement

Everything else is pretty much the same

Note you wouldnt call one proc 30 times to get 30 columns of one row.. just select the whole row
 
Back
Top