ASP error - HTMLEncode

ASP error - HTMLEncode

am 07.10.2004 14:40:47 von Support

Hey guys

I had an error that I managed to sort out the other day.
Even though it was an error on my part, thanx to those who
gave me suggestions. However, now I have a new prob.

I'm trying to access fields in an ADO recordset on Win
2000 Professional and IIS 5.0. I've managed to debug a few
errors in the code myself but I can't get past this one.
The error message on IE is:

Page cannot be displayed

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'HTMLEncode'
/PatentsDB/patentstable.asp, line 43

The code I'm running is:

Open the connection and recordset:
<%
Set cnn1 = Server.CreateObject("ADODB.Connection")
openStr = "driver={Microsoft Access Driver
(*.mdb)};DBQ=c:\inetpub\wwwroot\PatentsDB\PatentsDB.mdb"
cnn1.Open openStr,"",""

sql = "SELECT * FROM [tbdPatents];"
Set rsPnts = Server.CreateObject("ADODB.Recordset")
rsPnts.Open sql, cnn1
%>

I loop via:
Do While Not rsPnts.EOF

and create table cells via:

<%=Server.HTMLEncode(rsPnts.Fields
("txtPatentID").Value)%>
<%=Server.HTMLEncode(rsPnts.Fields
("txtGenericName").Value)%>
<%=Server.HTMLEncode(rsPnts.Fields
("txtBrandName").Value)%>
<%=Server.HTMLEncode(rsPnts.Fields
("txtManufacturer").Value)%>

This is where the error occurs. Why am I getting a type
mismatch?

Any suggestions?

Thanx
A-Face

Re: ASP error - HTMLEncode

am 07.10.2004 14:43:41 von McKirahan

"A-Face" wrote in message
news:3eac01c4ac6a$deb65a60$a501280a@phx.gbl...
> Hey guys
>
> I had an error that I managed to sort out the other day.
> Even though it was an error on my part, thanx to those who
> gave me suggestions. However, now I have a new prob.
>
> I'm trying to access fields in an ADO recordset on Win
> 2000 Professional and IIS 5.0. I've managed to debug a few
> errors in the code myself but I can't get past this one.
> The error message on IE is:
>
> Page cannot be displayed
>
> Error Type:
> Microsoft VBScript runtime (0x800A000D)
> Type mismatch: 'HTMLEncode'
> /PatentsDB/patentstable.asp, line 43
>
> The code I'm running is:
>
> Open the connection and recordset:
> <%
> Set cnn1 = Server.CreateObject("ADODB.Connection")
> openStr = "driver={Microsoft Access Driver
> (*.mdb)};DBQ=c:\inetpub\wwwroot\PatentsDB\PatentsDB.mdb"
> cnn1.Open openStr,"",""
>
> sql = "SELECT * FROM [tbdPatents];"
> Set rsPnts = Server.CreateObject("ADODB.Recordset")
> rsPnts.Open sql, cnn1
> %>
>
> I loop via:
> Do While Not rsPnts.EOF
>
> and create table cells via:
>
> <%=Server.HTMLEncode(rsPnts.Fields
> ("txtPatentID").Value)%>
> <%=Server.HTMLEncode(rsPnts.Fields
> ("txtGenericName").Value)%>
> <%=Server.HTMLEncode(rsPnts.Fields
> ("txtBrandName").Value)%>
> <%=Server.HTMLEncode(rsPnts.Fields
> ("txtManufacturer").Value)%>
>
> This is where the error occurs. Why am I getting a type
> mismatch?
>
> Any suggestions?
>
> Thanx
> A-Face
>

Why are you using "Server.HTMLEncode()"?

Have you tried your code without it?

Re: ASP error - HTMLEncode

am 07.10.2004 14:56:06 von Support

Such a simple solution, thanx. It's now working.

However, I do have another query. When opening the
connection, I'm met with an error if I add cursor, lock or
command types. If I take them out it works.

The connection is the same as in my previous post except
for the 7th line:
rsPnts.Open sql, cnn1, adOpenForwardOnly, adLockReadOnly,
adCmdText

The error I get is:

Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable
range, or are in conflict with one another.
/PatentsDB/patentstable.asp, line 13

Any suggestions?

Thanx
A-Face


>-----Original Message-----
>"A-Face" wrote in
message
>news:3eac01c4ac6a$deb65a60$a501280a@phx.gbl...
>> Hey guys
>>
>> I had an error that I managed to sort out the other day.
>> Even though it was an error on my part, thanx to those
who
>> gave me suggestions. However, now I have a new prob.
>>
>> I'm trying to access fields in an ADO recordset on Win
>> 2000 Professional and IIS 5.0. I've managed to debug a
few
>> errors in the code myself but I can't get past this one.
>> The error message on IE is:
>>
>> Page cannot be displayed
>>
>> Error Type:
>> Microsoft VBScript runtime (0x800A000D)
>> Type mismatch: 'HTMLEncode'
>> /PatentsDB/patentstable.asp, line 43
>>
>> The code I'm running is:
>>
>> Open the connection and recordset:
>> <%
>> Set cnn1 = Server.CreateObject("ADODB.Connection")
>> openStr = "driver={Microsoft Access Driver
>> (*.mdb)};DBQ=c:\inetpub\wwwroot\PatentsDB\PatentsDB.mdb"
>> cnn1.Open openStr,"",""
>>
>> sql = "SELECT * FROM [tbdPatents];"
>> Set rsPnts = Server.CreateObject("ADODB.Recordset")
>> rsPnts.Open sql, cnn1
>> %>
>>
>> I loop via:
>> Do While Not rsPnts.EOF
>>
>> and create table cells via:
>>
>> <%=Server.HTMLEncode(rsPnts.Fields
>> ("txtPatentID").Value)%>
>> <%=Server.HTMLEncode(rsPnts.Fields
>> ("txtGenericName").Value)%>
>> <%=Server.HTMLEncode(rsPnts.Fields
>> ("txtBrandName").Value)%>
>> <%=Server.HTMLEncode(rsPnts.Fields
>> ("txtManufacturer").Value)%>
>>
>> This is where the error occurs. Why am I getting a type
>> mismatch?
>>
>> Any suggestions?
>>
>> Thanx
>> A-Face
>>
>
>Why are you using "Server.HTMLEncode()"?
>
>Have you tried your code without it?
>
>
>.
>

Re: ASP error - HTMLEncode

am 07.10.2004 15:13:58 von McKirahan

"A-Face" wrote in message
news:173001c4ac6d$026b3690$a401280a@phx.gbl...
> Such a simple solution, thanx. It's now working.
>
> However, I do have another query. When opening the
> connection, I'm met with an error if I add cursor, lock or
> command types. If I take them out it works.
>
> The connection is the same as in my previous post except
> for the 7th line:
> rsPnts.Open sql, cnn1, adOpenForwardOnly, adLockReadOnly,
> adCmdText
>
> The error I get is:
>
> Error Type:
> ADODB.Recordset (0x800A0BB9)
> Arguments are of the wrong type, are out of acceptable
> range, or are in conflict with one another.
> /PatentsDB/patentstable.asp, line 13
>
> Any suggestions?
>
> Thanx
> A-Face

If it works without a cursor why would you want to use one?

Is your ASP page and database in the same folder; i.e. "PatentsDB"?
Is "PatentsDB" a subfolder under the ASP page's folder?
I'll presume the latter and use Server.MapPath() below.
This variation also uses a different DSN-less connection string.

<%
Option Explicit

'Const cDSN = "driver={Microsoft Access Driver(*.mdb)};DBQ="
Const cDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
Const cMDB = "PatentsDB\PatentsDB.mdb"

Dim objADO
objADO = Server.CreateObject("ADODB.Connection")
objADO.Open cDSN & ServerMapPath(cMDB)
Dim strSQL
strSQL = "SELECT * FROM [tbdPatents]"
Set objRST = Server.CreateObject("ADODB.Recordset")
objRST.Open strSQL, objADO

Do While Not objRST.EOF
%>

<%=objRST("txtPatentID")%>
<%=objRST("txtGenericName")%>
<%=objRST("txtBrandName")%>
<%=objRST("txtManufacturer")%>

<%
objRST.MoveNext
Loop
Set objRST = Nothing
Set objADO = Nothing
%>