Add a record directly to a table

  • Thread starter Thread starter Lennie Kuah via .NET 247
  • Start date Start date
L

Lennie Kuah via .NET 247

(Type your message here)
Hi All,
I am new to VB Dot Net, coming straght from VB6. I have tried andfailed trying to add a record to a table directly from a DataEntry Screen. From reading ref.books, it seems that I have tocreate a DataSet, populate it,then use that to update the table.I am utterly confused. Any suggestions or advices to point mein the right direction are most welcome and appreciated.Thanks.
 
Lennie,

The most straightforward way of doing this would be to use a DbCommand
object like SqlCommand, OleDbCommand, OdbcCommand etc. That way you can
execute a SQL statement on the data source and add a row as u wish.

This can be acheived using a DataSet also. DataSets would need to have their
rowstate to added (for newly added rows this would be default), and a call
to DataAdapter.Update would result in persisting that row per an
autogenerated (CommandBuilder) command, or the command you specify in
DataAdapter.InsertCommand..

Again this "gate keeper between disconnected and connected worlds" -- The
DataAdapter object is available in all .NET data providers - such as
SqlCLient, OdbcClient, OleDB etc.

This is very well explained in my first book in chapters # 4,5,6 (I think
LOL) and in my upcoming ADO.NET 2.0 book in Chapters 7,9 and 10.

Let me know if you have any other questions.

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/





(Type your message here)
Hi All,
I am new to VB Dot Net, coming straght from VB6. I have tried and failed
trying to add a record to a table directly from a Data Entry Screen. From
reading ref.books, it seems that I have to create a DataSet, populate
it,then use that to update the table. I am utterly confused. Any
suggestions or advices to point me in the right direction are most welcome
and appreciated. Thanks.
 
Back
Top