Click here to Skip to main content
16,012,025 members
Home / Discussions / Database
   

Database

 
QuestionInstrument Specifications Pin
chancomsats15-May-07 19:45
chancomsats15-May-07 19:45 
QuestionProblem in populating Datagrid with Stored Procedure? Pin
chand1015-May-07 19:18
chand1015-May-07 19:18 
AnswerRe: Problem in populating Datagrid with Stored Procedure? Pin
gauthee15-May-07 19:40
gauthee15-May-07 19:40 
QuestionRe: Problem in populating Datagrid with Stored Procedure? [modified] Pin
chand1015-May-07 20:06
chand1015-May-07 20:06 
AnswerRe: Problem in populating Datagrid with Stored Procedure? Pin
gauthee15-May-07 20:49
gauthee15-May-07 20:49 
GeneralRe: Problem in populating Datagrid with Stored Procedure? [modified] Pin
chand1015-May-07 21:35
chand1015-May-07 21:35 
GeneralRe: Problem in populating Datagrid with Stored Procedure? Pin
gauthee15-May-07 23:27
gauthee15-May-07 23:27 
QuestionAn unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll Pin
tomertro15-May-07 10:24
tomertro15-May-07 10:24 
i try the following code:

public void RunOleDbTransaction(string myConnString)
{
OleDbConnection myConnection = new OleDbConnection(myConnString);
myConnection.Open();

OleDbCommand myCommand = myConnection.CreateCommand();
OleDbTransaction myTrans;

// Start a local transaction
myTrans = myConnection.BeginTransaction(IsolationLevel.ReadCommitted);
// Assign transaction object for a pending local transaction
myCommand.Connection = myConnection;
myCommand.Transaction = myTrans;

try
{
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')";
myCommand.ExecuteNonQuery();
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')";
myCommand.ExecuteNonQuery();
myTrans.Commit();
Console.WriteLine("Both records are written to database.");
}
catch(Exception e)
{
try
{
myTrans.Rollback();
}
catch (OleDbException ex)
{
if (myTrans.Connection != null)
{
Console.WriteLine("An exception of type " + ex.GetType() +
" was encountered while attempting to roll back the transaction.");
}
}

Console.WriteLine("An exception of type " + e.GetType() +
" was encountered while inserting the data.");
Console.WriteLine("Neither record was written to database.");
}
finally
{
myConnection.Close();
}
}


but i get the following exception : An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: This OleDbTransaction has completed; it is no longer usable.

this exception occure when : myTrans.Rollback();

Please help me avoid this exception.

Please advice.

AnswerRe: An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll Pin
chand1015-May-07 22:05
chand1015-May-07 22:05 
GeneralRe: An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll Pin
tomertro16-May-07 0:27
tomertro16-May-07 0:27 
QuestionConvert text file to SQL table Pin
awara15-May-07 8:12
awara15-May-07 8:12 
AnswerRe: Convert text file to SQL table Pin
Pete O'Hanlon15-May-07 9:19
mvePete O'Hanlon15-May-07 9:19 
AnswerRe: Convert text file to SQL table Pin
andyharman15-May-07 22:59
professionalandyharman15-May-07 22:59 
AnswerRe: Convert text file to SQL table Pin
hueyjj16-May-07 3:30
hueyjj16-May-07 3:30 
QuestionField Type for SQL Table Pin
Yona Low15-May-07 8:09
Yona Low15-May-07 8:09 
AnswerRe: Field Type for SQL Table Pin
Pete O'Hanlon15-May-07 9:23
mvePete O'Hanlon15-May-07 9:23 
GeneralRe: Field Type for SQL Table Pin
Yona Low15-May-07 9:39
Yona Low15-May-07 9:39 
GeneralRe: Field Type for SQL Table Pin
Pete O'Hanlon15-May-07 9:52
mvePete O'Hanlon15-May-07 9:52 
QuestionStored Procedure problem Pin
david bagaturia15-May-07 5:51
david bagaturia15-May-07 5:51 
AnswerRe: Stored Procedure problem Pin
Gilbert Widmer15-May-07 6:03
Gilbert Widmer15-May-07 6:03 
GeneralRe: Stored Procedure problem Pin
david bagaturia15-May-07 6:09
david bagaturia15-May-07 6:09 
QuestionProblem Binding fields using a DataSet Pin
Quecumber25615-May-07 3:29
Quecumber25615-May-07 3:29 
AnswerRe: Problem Binding fields using a DataSet Pin
gauthee15-May-07 19:43
gauthee15-May-07 19:43 
Questiondata grid Pin
mfaizalc@yahoo.com15-May-07 1:47
mfaizalc@yahoo.com15-May-07 1:47 
AnswerRe: data grid Pin
gauthee15-May-07 21:10
gauthee15-May-07 21:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.