BeginTransaction error - Operation invalid at this time

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

Hey everyone, I'm struggling here...

I have the following in my Page_Load method of my code-
behind file:

if (IsPostBack)
{
OdbcConnection mkConn = new OdbcConnection
(Global.IngresConnectionString);

mkConn.Open();
OdbcTransaction trans = mkConn.BeginTransaction();
OdbcCommand mkCommand = new OdbcCommand(sqlString,
mkConn);
mkCommand.Transaction = trans;

...rest of code
}

When the page posts, I get a big fat "Server Error"
screen, with the following error:

ERROR [HY011] [CA][Ingres ODBC Driver]Operation invalid
at this time

The error is on the BeginTransaction line. The kicker is
that if I hit the browser's Refresh button at this time,
the page re-posts and goes on its merry way, creating the
transaction, running the sql statements, and commiting
the transaction.

So my question is, why on earth does it fail on a normal
posting of the page, but work on the refresh? This is
driving me bonkers!

Thanks in advance,
Brian
 
Brian,

There might be a problem with that particular ODBC driver (from Ingers). Make sure that it is built to support .NET. To know more about that error, generate an ODBC trace
and look in the trace. Search for "error" keyword and you should see something more meaningful. To generate an ODBC trace:

HOWTO: Generate an ODBC Trace with ODBC Data Source Administrator
http://support.microsoft.com/?id=274551

I hope this helps!


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
 
Brian said:
Hey everyone, I'm struggling here...

I have the following in my Page_Load method of my code-
behind file:

if (IsPostBack)
{
OdbcConnection mkConn = new OdbcConnection
(Global.IngresConnectionString);

mkConn.Open();
OdbcTransaction trans = mkConn.BeginTransaction();
OdbcCommand mkCommand = new OdbcCommand(sqlString,
mkConn);
mkCommand.Transaction = trans;

...rest of code
}

When the page posts, I get a big fat "Server Error"
screen, with the following error:

ERROR [HY011] [CA][Ingres ODBC Driver]Operation invalid
at this time

The error is on the BeginTransaction line. The kicker is
that if I hit the browser's Refresh button at this time,
the page re-posts and goes on its merry way, creating the
transaction, running the sql statements, and commiting
the transaction.

So my question is, why on earth does it fail on a normal
posting of the page, but work on the refresh? This is
driving me bonkers!

Thanks in advance,
Brian


Brian,

OpenLink Software provides high-performance ADO.NET Data Providers for
Ingres that will not exhibit this problem. We also provide an ODBC.NET
Bridge Data provider that can sit atop the CA-Ingres provided ODBC
Driver in order for you to work smoothly with ADO.NET.

You can download free 30 day evaluation Ingres or ODBC Data Providers
from:
http://www.openlinksw.com/download

Kingsley Idehen
OpenLink Software http://www.openlinksw.com/blog/~kidehen
 
Well I found the solution to my problem. All I needed to
do was to include the isolation level in the Transaction
constructor. I had to use IsolationLevel.Unspecified.

Thanks for the suggestions!
-Brian
 
Back
Top