Object reference not set to an instance of an object.

J

Joe C.

I inherited 2 web applications written in classic asp. These applications
were very long and used ADO 2.5 and due to limited budget we were to keep
them in ADO 2.5 and convert them to ASP.NET.
When the server is rebooted the first application to start will run fine and
continues to run as such. The second application to start will produce an
"Object reference not set to an instance of an object. " error.

here is a sample code shows where it fails:

Dim strId As String

ggConn.Open("Provider=SQLOLEDB.1;Password=password;Persist Security
Info=False;User ID=userID;Initial Catalog=mainDb;Data Source=SQL2Server")


Dim strSql As String

Dim RsRpt As New ADODB.Recordset()

Dim Rs As New ADODB.Recordset()

Rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient

Rs.Open("select * from [employees] ORDER BY [last_name], ggConn,
ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

strId = Rs.Fields("ID").Value '*** statement where I the application
fails




I am using ASP.NET and VB.NET, IIS 5, W2K server SP4, Any idea what might be
causing this error? I tried several solutions form MS knowledgebase without
any success. Your help is greatly appreciated and thank you in advance.
 
K

konsu

apparently, the dataset does not have a field called "ID". that's why you
crash.

konstantin
 
J

Joe C.

It certainly does.

konsu said:
apparently, the dataset does not have a field called "ID". that's why you
crash.

konstantin



Joe C. said:
I inherited 2 web applications written in classic asp. These applications
were very long and used ADO 2.5 and due to limited budget we were to keep
them in ADO 2.5 and convert them to ASP.NET.
When the server is rebooted the first application to start will run fine and
continues to run as such. The second application to start will produce an
"Object reference not set to an instance of an object. " error.

here is a sample code shows where it fails:

Dim strId As String

ggConn.Open("Provider=SQLOLEDB.1;Password=password;Persist Security
Info=False;User ID=userID;Initial Catalog=mainDb;Data Source=SQL2Server")


Dim strSql As String

Dim RsRpt As New ADODB.Recordset()

Dim Rs As New ADODB.Recordset()

Rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient

Rs.Open("select * from [employees] ORDER BY [last_name], ggConn,
ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

strId = Rs.Fields("ID").Value '*** statement where I the application
fails




I am using ASP.NET and VB.NET, IIS 5, W2K server SP4, Any idea what
might
be
causing this error? I tried several solutions form MS knowledgebase without
any success. Your help is greatly appreciated and thank you in advance.
 
W

William \(Bill\) Vaughn

Using ADOc in a .NET framework application is problematic. ADOc does not
create anything except Static cursors when you use the client-side
library--dynamic or keyset cursors don't make sense in an ASP application as
the state is not persisted between invocations. I think it would be far
(far) easier to simply recode the data layer to ADO.NET which is designed
specifically for ASP.NET applications.

hth
--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Joe C. said:
It certainly does.

konsu said:
apparently, the dataset does not have a field called "ID". that's why you
crash.

konstantin



Joe C. said:
I inherited 2 web applications written in classic asp. These applications
were very long and used ADO 2.5 and due to limited budget we were to keep
them in ADO 2.5 and convert them to ASP.NET.
When the server is rebooted the first application to start will run
fine
and
continues to run as such. The second application to start will produce an
"Object reference not set to an instance of an object. " error.

here is a sample code shows where it fails:

Dim strId As String

ggConn.Open("Provider=SQLOLEDB.1;Password=password;Persist Security
Info=False;User ID=userID;Initial Catalog=mainDb;Data Source=SQL2Server")


Dim strSql As String

Dim RsRpt As New ADODB.Recordset()

Dim Rs As New ADODB.Recordset()

Rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient

Rs.Open("select * from [employees] ORDER BY [last_name], ggConn,
ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

strId = Rs.Fields("ID").Value '*** statement where I the application
fails




I am using ASP.NET and VB.NET, IIS 5, W2K server SP4, Any idea what
might
be
causing this error? I tried several solutions form MS knowledgebase without
any success. Your help is greatly appreciated and thank you in advance.
 
M

MS

Thank you for the advice. I think I have a long project to convert! I never
mind paid overtime.



William (Bill) Vaughn said:
Using ADOc in a .NET framework application is problematic. ADOc does not
create anything except Static cursors when you use the client-side
library--dynamic or keyset cursors don't make sense in an ASP application as
the state is not persisted between invocations. I think it would be far
(far) easier to simply recode the data layer to ADO.NET which is designed
specifically for ASP.NET applications.

hth
--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Joe C. said:
It certainly does.

konsu said:
apparently, the dataset does not have a field called "ID". that's why you
crash.

konstantin



I inherited 2 web applications written in classic asp. These applications
were very long and used ADO 2.5 and due to limited budget we were to keep
them in ADO 2.5 and convert them to ASP.NET.
When the server is rebooted the first application to start will run fine
and
continues to run as such. The second application to start will
produce
an
"Object reference not set to an instance of an object. " error.

here is a sample code shows where it fails:

Dim strId As String

ggConn.Open("Provider=SQLOLEDB.1;Password=password;Persist Security
Info=False;User ID=userID;Initial Catalog=mainDb;Data Source=SQL2Server")


Dim strSql As String

Dim RsRpt As New ADODB.Recordset()

Dim Rs As New ADODB.Recordset()

Rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient

Rs.Open("select * from [employees] ORDER BY [last_name], ggConn,
ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)

strId = Rs.Fields("ID").Value '*** statement where I the
application
fails




I am using ASP.NET and VB.NET, IIS 5, W2K server SP4, Any idea what might
be
causing this error? I tried several solutions form MS knowledgebase
without
any success. Your help is greatly appreciated and thank you in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top