473,379 Members | 1,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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

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?
Nov 20 '05 #1
3 7063
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" <wm***@shemsystems.com> 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 thesame again...
--
Armin

.

Nov 20 '05 #2
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" <wm***@shemsystems.com> 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 thesame again...
--
Armin

.

Nov 20 '05 #3
"William Mild" <wm***@shemsystems.com> 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" <wm***@shemsystems.com> 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

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: DCM Fan | last post by:
SELECT ISNUMERIC('. ') 1 SELECT CAST('. ' AS ) Syntax error converting the varchar value '. ' to a column of data type . Any thoughts as to why SQL Server 7.0 considers '. ' to be...
4
by: Ray | last post by:
When a single-bit bitfield that was formed from an enum is promoted/cast into an integer, does ANSI C say anything about whether that integer should be signed or unsigned? SGI IRIX cc thinks it is...
3
by: John Howard | last post by:
Making the following call to a local MSAccess database works fine: Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) Dim intRows As Integer Dim strSQL As String Dim ds As New...
3
by: PK9 | last post by:
I am looking for assistance in pinpointing the cause of the following exception. I am getting a "Specified Cast is not valid" exception on my page. I am trying to populate a datagrid. One of my...
1
by: Daniel | last post by:
HI, <asp:TableCell BackColor="#000066" ID="tblcell" Width='<%# DataBinder.Eval(Container.DataItem, "PRODUCT_ID") %>'/> code at the above is displaying the message Specified cast is not valid....
4
by: Mike Cooper | last post by:
There is something about inherited classes I evidently don't know... I wrote the following class: Class Class1 inherits System.Windows.Forms.DataGridTextBoxColumn End Class There is...
21
by: John Howard | last post by:
Making the following call to a local MSAccess database works fine: Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) Dim intRows As Integer Dim strSQL As String Dim ds As New...
6
by: John-Arne Lillebų | last post by:
Hi. I run into this problem and i could need some help to solve it. The project is an ASP.NET Web project. Including code sample of the problem. Any idea what is causing the error message ?...
9
by: Ben | last post by:
Hello, I'm not a developper, so sorry if it's a stupid question... I'm trying to develop an application in vb.net and I have the following problem: I have some information in an array:...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.