Creating data table and data set

Hello,
I want to fill a data table that I created with a dataset created by vs.net. The reason is I have to rewrite this part of my application so that the data set handles the update to the Sql server table. I have already created the data table and the application was complete it is just that I used the SqlDataAdapter parameter .Update to update my database with a stored procedure. Well, it executes the procedure for every line. So, any suggestions or direction? I would like to do as little re-writing as possible.

Thanks

Shawn

[672 byte] By [ShawnTweter] at [2007-12-16]
# 1
Please Clarify...

MyDataAdapter.Fill(MyDataSet, MyDataTable)

Not sure if that what your saying...

DMan1 at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2
well, I have created a datatable that has two boolean columns in it so I can use a check box in the ui. I want to load that data table associated with the vs studio drag and drop created dataset. I quess a better question is: Is there a sql data type that will match the boolean column type so I don't have to pull out of table loop through the data and put back into origanal table. By table I mean DataTable.

Hope that clears things up a little.

thanks

Shawn

ShawnTweter at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 3
Sorry, Shawn ... that makes it less clear. Your first post doesn't seem to have anything to do with your second post. I'm still not clear on what you're asking.
BonnieB at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 4

Sorry, I myself and my whole week have been scatter brained.

I am developing a simple application that originally pulled into a DataReader object values from stored procedures. Those values were put into a DataTable and bound to a datagrid. The catch is only 2 fields need be editable and those 2 fields are just flags one was Y/N and the other was F or a blank (' '). To cut down user error I looped through the DataReader and change the editable flag fields to Boolean values which i had to create each column for the DataTable, all this to allow a check box(cut down user error). When I finally wanted to update the database I had to parse the flags back to the normal values and I used a stored procedure and the DataAdapter.Update command and let the stored proc handle the delete, update and insert. Well that method called the stored proc for each line and my sup want me to change the input procedures so that they dump the info into a table and fill a data set with that table and use the DataSet.update method to update the work table and then call a procedure to update the production table.

Well now that is even more confusing what I want is:

Not to have to rewrite the whole application (all though this is probably the smallest app I have written with this company).

To be able to implement what my sup wants and use the existing ui and design time DataTable.

Problems: the Boolean value, is there a Sql data type that will match the System.Boolen

Also if no match on the data type will it be possible to parse that dataSet11.tables[0] into my design time table and then put it back and still hold true to currency(just be able to update data using dataSet11.Update()).

Or will it mess with the need have primary constraint in the dataset to allow the update method to function correctly?
I am not sure any of these questions are valid just trying to shoot everything I am thinking of your way.

Please forgive me for this tread I have had the most scatter brained week ever!!!!
Thanks for you patients and help.

Shawn

ShawnTweter at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 5

A piece at a time here:

SQL has a 'bit' data type and it also has the ability to create custom data types...

The dataSet11.Update command is going to based on the underlying SQL command...

In order to do any updates on any table(correctly) you must utilize a primary key.

DMan1 at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 6
Shawn,

First of all, can you change the flags in your database to be of datatype bit? If not, then you'll have to parse like you've been doing. That part seems to work fine, if I'm interpreting what you've said correctly. ;-)

>>Well that method called the stored proc for each line and my sup want me to change the input procedures so that they dump the info into a table and fill a data set with that table and use the DataSet.update method to update the work table and then call a procedure to update the production table.<<

That's the way it's gonna work, no matter what you do. The .Update() method, behind the scenes, always runs an update one row at a time. Is this what your sup is objecting to?

BonnieB at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 7

I can change the the data types to bit although I have not had the chance to see it work with the column datatype(so the check box works directly with the bit). The issue is the DataAdapter.Update() method calling the stored procedure for each line updating.
ShawnTweter at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 8
Shawn,

If you use the Stored Proc with that DataAdapter and you use the .Update() method of that DataAdapter, then, yes, it will call the Stored Proc once for every modified row in your DataTable.

You mentioned something about updating a work table and *then* calling the Stored Proc .... well, I obviously don't know how your data is set up, so I can't say much about how you would go about doing this. You can execute a Stored Proc without using an .Update(), you simply use the SqlCommand.ExecuteNonQuery() method ... after setting the SqlCommand.CommandText to your Stored Proc name and adding any parameters to it's Parameter collection.

Does this help you at all?

BonnieB at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified