Can't save my data in the DB with ADO.NET

T

Torben Madsen

Hello,
I'm trying to save the changes back to the database, but it doesn't
work -could anybody help me?
I'm using a DataSet and the wierd thing is that I can save the changes in
the memory but not in the database :-/
I have tried to duplicate an example I found on msdn -but with no luck. The
sourcecode is in C#:

---------------------------------------------------------------------
Sourcecode
public void insertData(String tableName, ArrayList insertArray)
{
object[] iObj = new object[insertArray.Count];

for (int loopIndex = 0; loopIndex < insertArray.Count; loopIndex++)
{
iObj[loopIndex] = insertArray[loopIndex];
}

dataset.Tables[tableName].Rows.Add(iObj);
dataset.AcceptChanges();

autoGen = new OdbcCommandBuilder(oDataAdapter);
oDataAdapter.InsertCommand = autoGen.GetInsertCommand();

oTransaction = null;
oConnection = new OdbcConnection(myConnection);
oConnection.Open();
oTransaction = oConnection.BeginTransaction();
oDataAdapter.Update(dataset, tableName);
oTransaction.Commit();
oConnection.Close();
}
---------------------------------------------------------------------
Sourcecode

thanks

best regards
Torben
 
G

Greg

You need to create your UpdateCommand.

One of three ways:

manually
commandbuilder
data form wizard
 

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

Similar Threads

Can't insert in my table 2
Can't insrt in my table 1

Top