Cant insert and delete

Hi,

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

publicstaticint 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

[1782 byte] By [angka] at [2008-2-25]
# 1

Please some1 pls help me or send me any useful link and i will figure out my self thanks..

angka at 2007-9-9 > top of Msdn Tech,SQL Server,SQL Server Data Access...
# 2
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

VaughnWashington at 2007-9-9 > top of Msdn Tech,SQL Server,SQL Server Data Access...
# 3
oh ya how can i forget that.. thanks alot.. Big Smile
angka at 2007-9-9 > top of Msdn Tech,SQL Server,SQL Server Data Access...

SQL Server

Site Classified