-1

Is it possible to add a new row to a database using DataSet? When I created a new DataSet and dragged the table from the database I could see that in the DataSet methods there was one called insert that in the preview showed a parameterized query almost like a stored procedure to insert data.

However, when I create a new object of that DataSet in the methods there is nothing called insert or nothing that says I can insert the data from a DataSet into a database.

1

From Msdn, you need to use the TableAdapter that is created:

If you do not have an instance available, instantiate the TableAdapter you want to use.

Example:

NorthwindDataSetTableAdapters.RegionTableAdapter regionTableAdapter = 
    new NorthwindDataSetTableAdapters.RegionTableAdapter();

regionTableAdapter.Insert(5, "NorthWestern");

Check the above link for more examples.

  • I tnink that I will try EF since i'ts really straightforward and allows to use the tables as classes which is really really useful. However I can't find any info about parameterization when using EF. Does the commands INSERT and so on have built-in parameterization? – LikeIfYouCaredAboutMyName Jun 19 '16 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.