|
| |
|
|
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! </b>
<%
%>
</td>
</b>
<p></p>
<p></p>
<%
End If
rst.Close
'rst2.Close
con.Close
%></html>
|
|
|
|
rrnml
Posts: 197 Joined: 9/20/2004 Status: offline
|
RE: Type mismatch error - 5/16/2005 15:59:32
It says line 70.
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
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
|
|
|
|
rrnml
Posts: 197 Joined: 9/20/2004 Status: offline
|
RE: Type mismatch error - 5/16/2005 16:23:07
No.
|
|
|
|
rrnml
Posts: 197 Joined: 9/20/2004 Status: offline
|
RE: Type mismatch error - 5/16/2005 16:23:49
Ok. I'll do that.
|
|
|
|
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?
|
|
|
|
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! </b>
<%
%>
</td>
</b>
<p></p>
<p></p>
<%
End If
rst.Close
con.Close
%></html>
|
|
|
|
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.
|
|
|
|
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!
|
|
|
|
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?
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
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?
|
|
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
|
|
|