[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

Error in OleDb from ASP.NET page (Bug?)

Erik Marcussen

10/17/2002 10:27:00 AM

Hi
We are getting a serious error in our mobile application. The application
uses STA on some pages because they use CDO that needs a STA environment.
The error *only* rise on these pages where aspCompat = "true". No problem on
MTA pages. It might be a bug.

The problem is that an exception is thrown from the OleDb namespace of the
.NET framework when getting something or updating something in the database.
The error does not happen all the time, or on every request to the database.
Most often it happens when a session has timed out and a new user (new
session) logs on. It never happens right after a server restart. We use a
database layer so exactly the same code is executed on the MTA and STA
pages.

The application uses Session variables. These are cleaned up on SessionEnd.
CDO objects are not used in Session variables, they are created, used and
cleaned up on every page in Onload and Unload event handlers. Apart from
that I cannot see that our application is unlike any normal ASP.NET
application.

The exceptions raised are either a no interface com exception (Type
System.Data.OleDb.OleDbException, ErrorNumber: -2147467262), or a
System.InvalidCastExcaption as shown below.

We would greatly appreciate insights into this problem. It is very important
that we solve this.
Regards Erik Marcussen
Unit 4 Agresso R&D - MIT Early Adaptor

This is example of the code in the database layer that forces the error:
MSInfo.Titles.GetTitle():
sSQL = "SELECT s_title FROM asyswbtitles"+Language+ " WHERE i_id = '" + id +
"'";
string title = (string)db.GetSingleValue(sSQL);

mobileservices.DataAccess.Data.GetSingleValue():
public object GetSingleValue(string sql)
{
_command = new OleDbCommand(sql,_conn);
openConnection();
return _command.ExecuteScalar(); // The error comes from here
}

Error Specifics:
Server Error in '/ams/exconn' Application.
----------------------------------------------------------------------------
----

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:


[InvalidCastException: Specified cast is not valid.]
System.Data.OleDb.OleDbConnection.IOpenRowset() +12
System.Data.OleDb.OleDbCommand.ExecuteTableDirect(CommandBehavior
behavior, Object& executeResult) +128
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior,
Object& executeResult) +82
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method) +112
System.Data.OleDb.OleDbCommand.ExecuteScalar() +87
mobileservices.Msinfo.Titles.GetTitle(String id) +210
agrmail.Mailmenu.SetTitles() +75
agrmail.Mailmenu.Page_Load(Object sender, EventArgs e) +164
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.MobileControls.MobilePage.OnLoad(EventArgs e) +135
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724