Can anyone help me? I am using MSDE 2000 with VS.NET. I can SELECT from the database but i cant insert and delete and update. Below are my code
public static int Add(string tmpSql, string connectionString)
{
oleConn = new OleDbConnection(connectionString);
oleConn.Open();
oleTran = oleConn.BeginTransaction();
try
{
oleCom = new OleDbCommand(tmpSql, oleConn);
oleCom.Transaction = oleTran;
int a =oleCom.ExecuteNonQuery();
return(0);
}
catch
{
oleTran.Rollback();
return(1);
}
finally
{
oleConn.Close();
}
}
my int a give a value of 1 but when i look at the database the data is not inserted? but my primary key of the table did increase by one. what went wrong? is it due to my configuration which dun allow my to insert and update? help. Thank you
Please some1 pls help me or send me any useful link and i will figure out my self thanks..
|||Is it possible that you need to explicitly commit your transaction inside your try block before returning? In the example code on MSDN at the link below the transaction is explicitly committed.http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoledboledbconnectionclassbegintransactiontopic.asp
Hope this helps,
Vaughn|||oh ya how can i forget that.. thanks alot..
No comments:
Post a Comment