OutFront Forums
     Home    Register     Search      Help      Login    

Follow Us
On Facebook
On Twitter
RSS
Via Email

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

Sponsors
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

 

Type mismatch error

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP, PHP, and Database >> Type mismatch error
Page: [1] 2   next >   >>
 
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
Type mismatch error - 5/16/2005 15:52:37   
Not sure what a type mismatch error is. And I'm not sure I've gone about this query the right way. I have a query where you can search by either a keyword or by a user. I'm not sure I have it right. Well obviously it's not right if I'm getting an error! Anyway if anyone can see what I've done wrong please let me know. Here's the code...... Thanks.

' Create the SQL Query String
strParm1 = Request.Form("fdate")
strParm2 = Request.Form("tdate")
strSearchterm = Request.Form("searchterm")
strUser = Request.Form("scname")
Response.Write strParm1
Response.Write strParm2
Response.Write strUser

If strSearchterm <> "" then
 strSQLWhere = " (DestHost like '%" & strSearchterm & "')  "
Else
If strUser <> "" then
   strSQLWhere = " (ClientUserName like '%" & strUser & "')  "
 Else
   strSQLWhere = " "
 End If
End If
strSQL = " select DISTINCT DestHost " &_
  " from WebProxyLog " & _
  " where (DestHost like '%" & strSearchterm & "%') " & _ 
  " and (logDate between '" & strParm1 & "' and '" & strParm2 & "') " 
   strSQLWhere

strSQL2 = " select ClientUserName " &_
   " from WebProxyLog " & _
   " where (ClientUserName like '%" & strUser & "%') " & _
   " and (logDate between '" & strParm1 & "' and '" & strParm2 & "') " 
      
Response.write strSQL
Response.write strSQL2
server.ScriptTimeOut = 600
rst.Open strSQL, con, adOpenKeyset, adLockOptimistic
rst2.Open strSQL2, con, adOpenKeyset, adLockOptimistic
' Only display records if there are records in the recordset
If NOT rst.EOF then
 'Display the header
%>
<div align="center">
<p align="center"><b>Internet Destinations </b> </p>
<p align="center"><b>from <%=Request.Form("fdate")%></b></p>
<p align="center"><b>thru <%=Request.Form("tdate")%></b> </p>
<div align="center"><center>
<table BORDER="1" height="57" width="501">
 <tr>
   <td align="center" height="17" width="491"><b>Destinations</b></td>
 </tr>
<%
'Loop through the recordset until there are no more records
Do While Not rst.EOF
%>
<tr>
 <td align="center" height="29" width="491"><a href="InternetDestinations4.asp"><%=rst("DestHost")%>
 </a></td>

</tr>    
<% 

'If you forget this next statement, you will be stuck in a loop
rst.MoveNext
Loop
 
Else
%>

<b>
 <tr>
   <td align="center" height="23" width="491">No records in recordset!&nbsp; </b>
<%

%>
</td>
   
 </b>
   
<p></p>
   
<p></p>

   
<%
End If

rst.Close
'rst2.Close
con.Close
%></html>

Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Type mismatch error - 5/16/2005 15:56:29   
Which line?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/16/2005 15:59:32   
It says line 70.

(in reply to Spooky)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:00:22   
That doesnt look like the whole script - so which is line 70?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:07:32   
Looks like it's an empty line. I'll give you the rest of the code that I didn't include.


<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>Internet Destinations</title>

<meta name="Microsoft Border" content="tb">
</head>
<body>
<%
Dim con 
Dim rst
Dim rst2
Dim strSQL
Dim strSQL2
Dim strParm1
Dim strParm2
Dim strSearchterm
Dim strUser
Dim strSQLWhere
Const adOpenKeyset = 0
Const adLockOptimistic = 1
'Create the objects 
Set con = Server.CreateObject("ADODB.Connection") 
Set rst = Server.CreateObject("ADODB.Recordset") 
Set rst2 = Server.CreateObject("ADODB.Recordset") 
' Open the connection to NMLFIRE 
con.Open "ProxyDB", "sqlquery", "querysql"
con.CommandTimeout = 0

(in reply to Spooky)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:12:55   
Do you have a URL? and on a different subject, why are you opening rst2?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:15:55   
Well I'm on an intranet. As for the rst2, that was supposed to be commented out. Sorry about that. I can show you the form as well if you like.

(in reply to Spooky)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:17:33   
Can you copy and paste the exact error you see in your browser?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:18:53   



2005051620050516adriana
Microsoft VBScript runtime
error '800a000d'
Type mismatch
/Queries/InternetDestinations3.asp, line 70

(in reply to Spooky)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:22:20   
so by my count its this line? There arent any included files?

<p align="center"><b>from <%=Request.Form("fdate")%></b></p>

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:23:07   
No.

(in reply to Spooky)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:23:17   
If rst2 isnt going to be used, do you want to remove the associated code and try again?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to Spooky)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:23:49   
Ok. I'll do that.

(in reply to Spooky)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:29:00   
Ok I tried that and it said line 67 type mismatch this time. Then I took out the strSQLWhere and it ran. What I was trying to say was if the the search box is blank then run the code to find the keyword else do the other sql statement which is to search by user.  Obviously, the way I wrote it was wrong. Got any ideas?

(in reply to rrnml)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:33:49   
Post the full existing code?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:35:22   
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>Internet Destinations</title>

<meta name="Microsoft Border" content="tb">
</head>
<body>
<%
Dim con 
Dim rst
Dim strSQL
Dim strParm1
Dim strParm2
Dim strSearchterm
Dim strUser
Dim strSQLWhere
Const adOpenKeyset = 0
Const adLockOptimistic = 1
'Create the objects 
Set con = Server.CreateObject("ADODB.Connection") 
Set rst = Server.CreateObject("ADODB.Recordset") 
' Open the connection to NMLFIRE 
con.Open "ProxyDB", "sqlquery", "querysql"
con.CommandTimeout = 0
' Create the SQL Query String
strParm1 = Request.Form("fdate")
strParm2 = Request.Form("tdate")
strSearchterm = Request.Form("searchterm")
strUser = Request.Form("scname")
Response.Write strParm1
Response.Write strParm2
Response.Write strUser

If strSearchterm <> "" then
 strSQLWhere = " (DestHost like '%" & strSearchterm & "')  "
Else
If strUser <> "" then
   strSQLWhere = " (ClientUserName like '%" & strUser & "')  "
 Else
   strSQLWhere = " "
 End If
End If
strSQL = " select DISTINCT DestHost " &_
  " from WebProxyLog " & _
  " where (DestHost like '%" & strSearchterm & "%') " & _ 
  " and (logDate between '" & strParm1 & "' and '" & strParm2 & "') " 

strSQL2 = " select ClientUserName " &_
   " from WebProxyLog " & _
   " where (ClientUserName like '%" & strUser & "%') " & _
   " and (logDate between '" & strParm1 & "' and '" & strParm2 & "') " 
      
Response.write strSQL
Response.write strSQL2
server.ScriptTimeOut = 600
rst.Open strSQL, con, adOpenKeyset, adLockOptimistic
' Only display records if there are records in the recordset
If NOT rst.EOF then
 'Display the header
%>
<div align="center">
<p align="center"><b>Internet Destinations </b> </p>
<p align="center"><b>from <%=Request.Form("fdate")%></b></p>
<p align="center"><b>thru <%=Request.Form("tdate")%></b> </p>
<div align="center"><center>
<table BORDER="1" height="57" width="501">
 <tr>
   <td align="center" height="17" width="491"><b>Destinations</b></td>
 </tr>
<%
'Loop through the recordset until there are no more records
Do While Not rst.EOF
%>
<tr>
 <td align="center" height="29" width="491"><a href="InternetDestinations4.asp"><%=rst("DestHost")%>
 </a></td>

</tr>    
<% 

'If you forget this next statement, you will be stuck in a loop
rst.MoveNext
Loop
 
Else
%>

<b>
 <tr>
   <td align="center" height="23" width="491">No records in recordset!&nbsp; </b>
<%

%>
</td>
   
 </b>
   
<p></p>
   
<p></p>

   
<%
End If

rst.Close
con.Close
%></html>


(in reply to Spooky)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:39:06   
"strSQLWhere" isnt actually used by the code though?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:40:31   
I had it after the first sql statement before I took it out. If I put it back in I will get the type mismatch error.

(in reply to Spooky)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:43:23   
In your first example :

strSQL = " select DISTINCT DestHost " &_
" from WebProxyLog " & _
" where (DestHost like '%" & strSearchterm & "%') " & _
" and (logDate between '" & strParm1 & "' and '" & strParm2 & "') "
strSQLWhere


Should be more like :

strSQL = " select DISTINCT DestHost " &_
" from WebProxyLog " & _
" where (DestHost like '%" & strSearchterm & "%') " & _
" and (logDate between '" & strParm1 & "' and '" & strParm2 & "') AND "& strSQLWhere


_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/16/2005 16:51:34   
Ok that runs with no errors, but I get no records returned and I know there are hundreds of records. This is what gets passed.





2005050220050516nancy select DISTINCT DestHost from WebProxyLog where (DestHost like '%%') and (logDate between '20050502' and '20050516') AND (ClientUserName like '%nancy') select ClientUserName from WebProxyLog where (ClientUserName like '%nancy%') and (logDate between '20050502' and '20050516')

No records in recordset! 


(in reply to Spooky)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Type mismatch error - 5/17/2005 15:20:56   
Youll need to check your SQL statement and isolate the parts that either arent working or not providing you with the info you require.
Your SQL is specific to the records you want to see.
It may be your wild card format (when null) or your date format. It might simply be using an "AND" instead of an "OR"

<edit spelling>

< Message edited by Spooky -- 5/17/2005 15:52:42 >


_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to rrnml)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: Type mismatch error - 5/17/2005 15:31:18   
quote:

'20050502' and '20050516'


The date format would be my first guess if your host is in the US.  However, I can't tell from your user profile.  When I pass to my SQL Server, I send it in the format:

'mm/dd/yyyy'

so today is

'05/17/2005'

Is this SQL Server?

EDIT:  I have since been informed that your date format should work fine - sorry.  That's why I'm here - to learn more...:)

< Message edited by rdouglass -- 5/17/2005 15:51:23 >


_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to Spooky)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/17/2005 18:24:33   
Thanks guys I'm still working on it. I'll have to check out the SQL statement like you said. Would it be possible to put the two SQL statements together instead of having two?

(in reply to rdouglass)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Type mismatch error - 5/17/2005 19:24:39   
You want to use strSQL2 as well?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to rrnml)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/17/2005 19:27:54   
Yeah well what I want to do is be able to search by either the keyword which is strSearchterm or by user which is strUser. Can I do that in one SQL statement or do I need two? My brain is just so fried because I've tried many different ways and I get different results but not the way I want it.

(in reply to Spooky)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/17/2005 19:34:09   
Hey I don't mean to bail but I'll be back in tomorrow. Thanks for your help. I'll be working on it tonight likely. Hopefully, with much progress. Thanks again.

(in reply to rrnml)
BeTheBall

 

Posts: 6487
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Type mismatch error - 5/17/2005 19:34:35   
What if you replace:

If strSearchterm <> "" then
 strSQLWhere = " (DestHost like '%" & strSearchterm & "')  "
Else
If strUser <> "" then
  strSQLWhere = " (ClientUserName like '%" & strUser & "')  "
 Else
  strSQLWhere = " "
 End If
End If
strSQL = " select DISTINCT DestHost " &_
 " from WebProxyLog " & _
 " where (DestHost like '%" & strSearchterm & "%') " & _ 
 " and (logDate between '" & strParm1 & "' and '" & strParm2 & "') " 

strSQL2 = " select ClientUserName " &_
  " from WebProxyLog " & _
  " where (ClientUserName like '%" & strUser & "%') " & _
  " and (logDate between '" & strParm1 & "' and '" & strParm2 & "') " 
     
Response.write strSQL


with:

If strSearchterm <> "" then
 strSQLWhere = " (DestHost like '%" & strSearchterm & "')  "
Else
If strUser <> "" then
   strSQLWhere = " (ClientUserName like '%" & strUser & "')  "
 Else
   strSQLWhere = " "
 End If
End If
strSQL = " select DISTINCT DestHost " &_
  " from WebProxyLog " & _
  " where "&strSQLWhere&"" & _ 
  " and (logDate between '" & strParm1 & "' and '" & strParm2 & "') "  
      
Response.write strSQL



_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to rrnml)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Type mismatch error - 5/17/2005 19:36:54   
If strSearchterm <> "" then
 strSQLWhere = " AND  (DestHost like '%" & strSearchterm & "')  "
Else
If strUser <> "" then
   strSQLWhere = " AND  (ClientUserName like '%" & strUser & "')  "
 Else
   strSQLWhere = " "
 End If
End If
strSQL = " select DISTINCT DestHost " &_
  " from WebProxyLog " & _
  " where (logDate between '" & strParm1 & "' and '" & strParm2 & "')  "&strSQLWhere  
      
Response.write strSQL


As above incase strSQLWhere is null

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to BeTheBall)
BeTheBall

 

Posts: 6487
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Type mismatch error - 5/17/2005 20:04:24   
Just thought of that myself, of course, Spooky already caught it.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to Spooky)
rrnml

 

Posts: 197
Joined: 9/20/2004
Status: offline

 
RE: Type mismatch error - 5/18/2005 12:02:00   
This seems to make more sense as it will allow you to search by keyword OR by user. And it eliminates the redundancy in the code I had before. However it doesn't return any records at all. Any idea why?

(in reply to BeTheBall)
Page:   [1] 2   next >   >>

All Forums >> Web Development >> ASP, PHP, and Database >> Type mismatch error
Page: [1] 2   next >   >>
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts