PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 1.00 average.

Cast from type 'Field' to type 'Integer' is not valid

 
 
William Mild
Guest
Posts: n/a
 
      28th Aug 2003
I am porting old Dreamweaver generated ASP code to
ASP.NET (VBScript to VB.NET).
Error: Cast from type 'Field' to type 'Integer' is not
valid
The error occurs on the line which says "rsStudents =
Server.CreateObject("ADODB.Recordset")".


if (Request.QueryString("StudentID") <> "") then
rsStudents__MMColParam = Request.QueryString("StudentID")

Dim rsStudents
rsStudents = Server.CreateObject("ADODB.Recordset")
rsStudents.ActiveConnection = MM_cnReportCards_STRING
rsStudents.Source = "SELECT * FROM dbo.Student WHERE
StudentID = " & Replace
(rsStudents__MMColParam, "'", "''") & ""
rsStudents.CursorType = 0
rsStudents.CursorLocation = 2
rsStudents.LockType = 3
rsStudents.Open()
Dim rsStudents_numRows As Integer = 0

Any ideas, besides rewriting the whole thing using a
datareader?
 
Reply With Quote
 
 
 
 
William Mild
Guest
Posts: n/a
 
      28th Aug 2003
Hi Armin. Before I posted this, I said to myself. "Ok,
self. Now check that code and make sure there isn't
a .Value that you missed! And I checked it, but I can't
find a .Value that I missed." But thanks for the
suggestion.
>-----Original Message-----
>"William Mild" <(E-Mail Removed)> schrieb
>> I am porting old Dreamweaver generated ASP code to
>> ASP.NET (VBScript to VB.NET).
>> Error: Cast from type 'Field' to type 'Integer' is not
>> valid
>> The error occurs on the line which says "rsStudents =
>> Server.CreateObject("ADODB.Recordset")".
>>
>>
>> if (Request.QueryString("StudentID") <> "") then
>> rsStudents__MMColParam = Request.QueryString

("StudentID")
>>
>> Dim rsStudents
>> rsStudents = Server.CreateObject("ADODB.Recordset")
>> rsStudents.ActiveConnection = MM_cnReportCards_STRING
>> rsStudents.Source = "SELECT * FROM dbo.Student WHERE
>> StudentID = " & Replace
>> (rsStudents__MMColParam, "'", "''") & ""
>> rsStudents.CursorType = 0
>> rsStudents.CursorLocation = 2
>> rsStudents.LockType = 3
>> rsStudents.Open()
>> Dim rsStudents_numRows As Integer = 0
>>
>> Any ideas, besides rewriting the whole thing using a
>> datareader?

>
>
>In your last thread you solved the problem by

adding ".value". I'd do the
>same again...
>
>
>--
>Armin
>
>.
>

 
Reply With Quote
 
William Mild
Guest
Posts: n/a
 
      28th Aug 2003
Found the bug. And I think there is some kind of bug in
the VS.NET debugger. It was a missing ".Value" but the
debugger gave wrong line number. I had an include file
where the the ".Value" was missing. I found it by moving
a "respond.end" through the code until an error
generated. Eventually, I was putting the "respond.end"
into the include file until I saw the missing ".Value".
The strange thing is that, when I tried to reproduce the
bug by taking out the ".Value," the error page produced
the correct error. So, I can't pass this one on the
Microsoft for review.
>-----Original Message-----
>"William Mild" <(E-Mail Removed)> schrieb
>> I am porting old Dreamweaver generated ASP code to
>> ASP.NET (VBScript to VB.NET).
>> Error: Cast from type 'Field' to type 'Integer' is not
>> valid
>> The error occurs on the line which says "rsStudents =
>> Server.CreateObject("ADODB.Recordset")".
>>
>>
>> if (Request.QueryString("StudentID") <> "") then
>> rsStudents__MMColParam = Request.QueryString

("StudentID")
>>
>> Dim rsStudents
>> rsStudents = Server.CreateObject("ADODB.Recordset")
>> rsStudents.ActiveConnection = MM_cnReportCards_STRING
>> rsStudents.Source = "SELECT * FROM dbo.Student WHERE
>> StudentID = " & Replace
>> (rsStudents__MMColParam, "'", "''") & ""
>> rsStudents.CursorType = 0
>> rsStudents.CursorLocation = 2
>> rsStudents.LockType = 3
>> rsStudents.Open()
>> Dim rsStudents_numRows As Integer = 0
>>
>> Any ideas, besides rewriting the whole thing using a
>> datareader?

>
>
>In your last thread you solved the problem by

adding ".value". I'd do the
>same again...
>
>
>--
>Armin
>
>.
>

 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      28th Aug 2003
"William Mild" <(E-Mail Removed)> schrieb
> Hi Armin. Before I posted this, I said to myself. "Ok,
> self. Now check that code and make sure there isn't
> a .Value that you missed! And I checked it, but I can't
> find a .Value that I missed." But thanks for the
> suggestion.
> >-----Original Message-----
> >"William Mild" <(E-Mail Removed)> schrieb
> >> I am porting old Dreamweaver generated ASP code to
> >> ASP.NET (VBScript to VB.NET).
> >> Error: Cast from type 'Field' to type 'Integer' is not
> >> valid
> >> The error occurs on the line which says "rsStudents =
> >> Server.CreateObject("ADODB.Recordset")".
> >>
> >>
> >> if (Request.QueryString("StudentID") <> "") then
> >> rsStudents__MMColParam = Request.QueryString

> ("StudentID")
> >>
> >> Dim rsStudents


Hmm.... Is this the VB.NET code? Did you enable Option Strict?


--
Armin

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: Cast From String to type Integer not valid =?Utf-8?B?TWljaGFlbA==?= Microsoft VB .NET 2 1st Jul 2005 07:26 PM
Cast from type 'DBNull' to type 'String' is not valid. =?Utf-8?B?RGF2ZSBCeXJvbg==?= Microsoft Dot NET 3 3rd Sep 2004 07:15 AM
Cast from type 'DBNull' to type 'String' is not valid. when creating dataset troutbum Microsoft ADO .NET 5 13th Mar 2004 01:30 PM
Re: Cast from type 'Field' to type 'String' is not valid. Herfried K. Wagner [MVP] Microsoft VB .NET 0 28th Aug 2003 12:03 AM
Re: Cast from type 'Field' to type 'String' is not valid. Armin Zingler Microsoft VB .NET 0 27th Aug 2003 11:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:35 AM.