
April 24th, 2007, 01:50 AM
|
|
Registered User
|
|
Join Date: Apr 2007
Posts: 1
Time spent in forums: 15 m 22 sec
Reputation Power: 0
|
|
Data type mismatch in criteria expression.
i have problem with the following asp codes , please help its urgentthis is my login .asp
Code:
<html><form name="form1" method="post" action="display.asp"><label>enter your cds no:</label>
<input name="dname" type="number" value="">
<input type="submit" name="Submit" value="Submit">
</form></html>
[B]when i post the input to the next page,am getting the following error message  ata type mismatch in criteria expression,am trying to retrieve information from database according to the user input inthe textbox. this is the code for display.asp[/B
Code:
]<%@ LANGUAGE="VBSCRIPT" %>
<%
Dim objConn ' Our Connection Object
Dim objRS ' Our Recordset Object
Dim SQL2 ' Our SQL String to access the database
Dim strConnection ' Our Connection string to access the database
Dim i ' a counter variable
dim rg,RS
' -- Create objects
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
' -- Connection String Value
strConnection = "FILEDSN=login.dsn"
' -- Open the Connection
objConn.Open strConnection
rg=request.Form("dname")
' -- Our SQL Statement
SQL2 = "SELECT Firstname,Surname FROM tblMembers where ID='"&rg&"'"
'SQL2 = "SELECT * FROM tblMembers where ID=254"
'response.Write(rg)
' -- Populate our Recordset with data
set RS = objConn.Execute(SQL2)
'response.Write"welcome"&rs.Fields(i)
if (RS.BOF and RS.EOF) then
response.write "No records found"
response.end
End if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<TABLE BORDER="1" CELLPADDING="2" CELLSPACING="1" WIDTH="100%">
<%
' -- Output the Field Names as the first row in the table
Response.Write "<TR BGCOLOR=""#CCCCCC"">"
For i = 0 to RS.Fields.Count - 1
Response.Write "<TH><FONT FACE=""ARIAL"" SIZE=""2"">" & RS.Fields(i).Name & "</FONT></TH>"
Next
Response.write "</TR>"
' -- Now output the contents of the Recordset
RS.MoveFirst
Do While Not RS.EOF
' -- output the contents
Response.Write "<TR>"
For i = 0 to RS.Fields.Count - 1
Response.Write "<TD><FONT FACE=""ARIAL"" SIZE=""1"">" &RS.Fields(i) & "</FONT></TD>"
Next
Response.write "</TR>"
' -- move to the next record
RS.MoveNext
Loop
RS.Close
set RS = Nothing
objConn.Close
set objConn = Nothing
%>
</TABLE>
</BODY>
</HTML>

|