Object reference not set to an instance of an object.
-
I'm haveing problems with opening a connection using Odbc in an ASP.NET page. First it starts of well and good, but after a while I'm receiving the error: Object reference not set to an instance of an object. I'm sure I'm closing the connections each time I use them, but I cannot understand why this error is happening. Does anybody know? Andrew
-
I'm haveing problems with opening a connection using Odbc in an ASP.NET page. First it starts of well and good, but after a while I'm receiving the error: Object reference not set to an instance of an object. I'm sure I'm closing the connections each time I use them, but I cannot understand why this error is happening. Does anybody know? Andrew
Have you tried debugging? Where is the error occuring?
-
Have you tried debugging? Where is the error occuring?
yes, the error is occouring on cn.open (where cn is the set OdbcConnection). The following is the stack trace: [NullReferenceException: Object reference not set to an instance of an object.] System.Data.Common.Odbc32.SQLFreeHandle(Int16 HandleType, HandleRef StatementHandle) +0 System.Data.Odbc.DBCWrapper.CloseAndRelease() +191 System.Data.Odbc.OdbcConnection.DisposeClose() +311 System.Data.Odbc.OdbcConnection.Open() +638 Andrew
-
yes, the error is occouring on cn.open (where cn is the set OdbcConnection). The following is the stack trace: [NullReferenceException: Object reference not set to an instance of an object.] System.Data.Common.Odbc32.SQLFreeHandle(Int16 HandleType, HandleRef StatementHandle) +0 System.Data.Odbc.DBCWrapper.CloseAndRelease() +191 System.Data.Odbc.OdbcConnection.DisposeClose() +311 System.Data.Odbc.OdbcConnection.Open() +638 Andrew
Good now look at the objects, which one is null? Are you sure that cn is valid?
-
Good now look at the objects, which one is null? Are you sure that cn is valid?
-
I'm haveing problems with opening a connection using Odbc in an ASP.NET page. First it starts of well and good, but after a while I'm receiving the error: Object reference not set to an instance of an object. I'm sure I'm closing the connections each time I use them, but I cannot understand why this error is happening. Does anybody know? Andrew
I don't see how an open or closed connection would make an object in your code null ? Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
-
I don't see how an open or closed connection would make an object in your code null ? Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
-
I'm starting to think that it may be a bug in mySQL or a microsoft program. Is there any way you can close all open connections to the database manually? Andrew
Yes, call sp_who, then KILL all the processes attached to your database ( thanks to whoever provided this solution, I asked this question only last week :-) ) Actually, that solves the problem in SQL Server. MySQL is kind of crap ( it doesn't even have stored procedures ), and in addition, sp_who is SQL Server specific, you'd need to find the equivelant in MySQL. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder