Best way to move data from gridview to Sql table

  • Thread starter Thread starter hartbypass
  • Start date Start date
H

hartbypass

Hello all.

I am trying to move data from my Gridview, essentially a dataset, to a
Sql table I created. I am trying to do this without having to create a
stored proc that I have to call every time I interate through a row.
So I am trying to see if this is conceptually possible.

Basically create a DataAdapter that is tied to my SqlServer table.
Fill that DataAdapter with the Dataset that I am using for my Gridview.
I assume I will have to do this my interating through the rows of my
DataSet and "Add" them to the DataAdapter. Then tun an update on the
DataAdapter and be done with it.

Any thoughts?

Greg
 
Greg,

You don't have to do any of this.

First, you ^should^ be creating a stored procedure to handle the insert,
update and delete operations on your table and then send them to your
SqlDataAdapter (in the form of SqlCommand objects).

Then, you can just call the Update method on your data adapter and then
it will cycle through the rows, calling the appropriate stored procedure.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top