ADO.net question?

G

Guest

I am fairly new to ASP.net having started with version 2. I have mostly used
the DataSource controls for manipulating data but i now need to some data
using ADO.net instead and a stored procedure in the SQL server database. As
far as i can work out, in order to insert a new row using ADO.net i need to
retreive the data base table into a datatable object, insert the row into the
DataTable and then run the update method of the DataAdapter object. So long
as i have a suitable DataCommand object and associated parameters set to the
InsertCommand property of the DataAdapter object then is will do the
business. This seems a very inefficient way to add a row to a table, it is
for an order entry system there are liekly to be hundreds of orders a day
entered. I don't want to have to read the whole orders table from the
database in order to just add a new record, so:

Is there a way to do this the doesn't involve me having to read anything
into a DataTable object, i.e. can i just create one with the relvent fields
etc and then add one row to it and then propagate this back to the DB in the
same way i would if i filled it from the DB.

If not would there be any problems with reading a very small subset of the
table into a datatable object and then using this to update the database
table, in other words will this delete all ther records in the database that
are not in the DataTable object.
 
K

Kevin Spencer

The DataTable is used when you need to fetch data and use it, and/or update
it or modify the contents of the underlying table. If all you need to do is
insert a record without seeing any of the other records, you can simply use
a Connection, Command, and a Stored Procedure or Query.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top