Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: How to write select staement using wildcards for access


Message #1 by "Manish Agarwal" <mpc@c...> on Wed, 23 May 2001 15:29:49
Hi there

I am using access as database

I am facing a problem in writing a select statement using wildcards.

In this statement i am using two values which are posted through a form 



both of the type string. But It is showing sometimes "syntax error" and 



sometimes when i change the syntax it shows "type mismatch".

Any help to solve this proble will be very kind of you all.

Thanks



Here is the code :



<html>

<head>

<title> Update Example</title>

</head>

<body>

<h1> Updating records using ado</h1>



<!--#include file="tools.asp"-->

<%



Dim n

Dim p

Dim con

Dim rst

Dim strSQL

Dim NAME

Const adOpenStatic = 3

const adLockReadOnly = 1

const adCmdText = 1 

n = Request.Form("name")

p = Request.Form("region")

set con = Server.CreateObject("ADODB.Connection")

con.Open "db1", "", ""



strSQL = "SELECT * FROM LOGIN WHERE USERID LIKE = '" & n* & _

    "' AND PASSWORD LIKE = '" & p* & "'"

Set rst = Server.CreateObject("ADODB.Recordset")

rst.Open strSQL,con, adOpenStatic, adLockReadOnly, adCmdText

if Not rst.EOF Then

%>



<table Border>

<tr>

<td><b>Update/DeLete</b></td>

<td><b>Name</b></td>

<td><b>Company</b></td>

<td><b>Address</b></td>

<td><b>Address1</b></td>

<td><b>City</b></td>

<td><b>Region</b></td>

<td><b>Zip</b></td>

<td><b>Country</b></td>

<td><b>Phone</b></td>

<td><b>Phone1</b></td>

<td><b>Email</b></td>

<td><b>Fax</b></td>

</tr>

<%



Do While Not rst.EOF

%>



<tr>

<td> <A HREF = "updaterecord.asp?NAME=<%=rst("sno")%>">

Update</A>/<A HREF = "delete.asp?NAME=<%=rst("sno")%>">Delete</A></td>

<td><%= rst("NAME")%></td>

<td><%= rst("COMPANY") %></TD>

<td><%= rst("ADD1") %></TD> 

<td><%= rst("ADD2") %></TD>

<td><%= rst("CITY") %></TD>

<td><%= rst("REGION") %></TD>

<td><%= rst("ZIP") %></TD>

<td><%= rst("COUNTRY") %></TD>

<td><%= rst("PHONE") %></TD>

<td><%= rst("PHONE1") %></TD>

<td><%= rst("EMAIL") %></TD>

<td><%= rst("FAX") %></TD>

</TR>

<%

rst.MoveNext

Loop

Else

%>

<B> No Records in Recordset</B>

<%



End If

rst.Close

con.Close

%>

</table>

</body>

</html>

Message #2 by "Ken Schaefer" <ken@a...> on Thu, 24 May 2001 12:12:19 +1000
http://www.adopenstatic.com/faq/likequeries.asp

Why Like * Queries Fail



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

----- Original Message -----

From: "Manish Agarwal" <mpc@c...>

To: "ASP Databases" <asp_databases@p...>

Sent: Wednesday, May 23, 2001 3:29 PM

Subject: [asp_databases] How to write select staement using wildcards for

access





: Hi there

: I am using access as database

: I am facing a problem in writing a select statement using wildcards.

: In this statement i am using two values which are posted through a form

:

: both of the type string. But It is showing sometimes "syntax error" and

:

: sometimes when i change the syntax it shows "type mismatch".

: Any help to solve this proble will be very kind of you all.

: Thanks





Message #3 by "Manish Agarwal" <mpc@c...> on Thu, 24 May 2001 07:46:28
Thanks Ken Your Suggestion really worked.

Thanks a lot























> http://www.adopenstatic.com/faq/likequeries.asp

> Why Like * Queries Fail

> 

> Cheers

> Ken

> 

> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> ----- Original Message -----

> From: "Manish Agarwal" <mpc@c...>

> To: "ASP Databases" <asp_databases@p...>

> Sent: Wednesday, May 23, 2001 3:29 PM

> Subject: [asp_databases] How to write select staement using wildcards for

> access

> 

> 

> : Hi there

> : I am using access as database

> : I am facing a problem in writing a select statement using wildcards.

> : In this statement i am using two values which are posted through a form

> :

> : both of the type string. But It is showing sometimes "syntax error" and

> :

> : sometimes when i change the syntax it shows "type mismatch".

> : Any help to solve this proble will be very kind of you all.

> : Thanks

> 

> 


  Return to Index