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
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