Tableadapter insert

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm quite new to using .net data access components and having problems when
trying to insert a new record to an MS SQL database single table.

First I tried to use a tableadapter generated by VS2005, like this :

messagesDataSetTableAdapter.Insert(paramaters);

This call does not create a new row neither in the DataSet nor in the
database. The database table remains empty, what I especially do not
understand, because msdn articles say that this member of the table adapter
directly interacts with the database not the DataSet. Anyway, I gave up.

For second, following some other msdn articles I tried this :

messagesDataSet.syslogentryRow newRow =
messagesDataSet.syslogentry.NewsyslogentryRow();
newRow.RawEntry = BytesToString(buffer);
newRow.TimeStamp = DateTime.Now;
newRow.Sender = senderEP.Address.ToString();
messagesDataSet.syslogentry.Rows.Add(newRow);
messagesDataSet.AcceptChanges();

This looks better for at least in the way that the inserted rows appear in
the bounded DataGridView, however tha database table still remains empty ?!

What am I missing to commit changes to the database ?

Thanks,
Laszlo


--
-----------------------------
Laszlo, Frank
Technotrade Informatics, Inc.
IT Director
MCSE, CCNA, TCE
-----------------------------
 
Hi Lac,

When generating a table adapter, it generate methods for you to use
datatable and/or direct record manipulation to interact with the database.
The "insert" method you used is one of the example for direct interaction.
Please check for the user rights, data integrity, etc. for your input. Or
can you provide any error messages (if any)?

In addition, before calling "AcceptChanges" method, please make sure you
have updated the back-end data storage (if any) or you may lost your changes
in the next udpate.

Raymond
 
Back
Top