Wrox Programmer Forums
|
Access ASP Using ASP with Microsoft Access databases. For Access questions not specific to ASP, please use the Access forum. For more ASP forums, please see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 5th, 2003, 01:25 PM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Incorrect SQL Syntax??!

I am trying to make data from an access database apear when a user enters in a username. This username (on an HTML form) is turned into a variable, (varname). I then run an SQL Select statement that compares the username entered (stored into the varname variable) and brings up other fields of the same record. Here is the code.
<html>
<head>
<title>ASP Script</title>
</head>
<%
dim rs
dim varname
varname=Request.form("name")
set rs=server.createobject("ADODB.recordset")
sqltext="SELECT * FROM people"
sqltext=sqltext& "Where lastname=" &varname&";"
rs.open sqltext, "DSN=test"
%>
Your First Name is <%rs("firstname")%>
<body>
</body>
</html>

I keep getting this error,

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.
/datatest/testname.asp, line 12

What is the correct way of referncing a string (text) variable in a SQL Select statement?!!

I have tried putting ' around the varname like this........

Where lastname='" &varname&"';"

Please email or post, thank you very much
 
Old June 5th, 2003, 01:37 PM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ahhhi figured it out i was missing a space betwen the sqltext parts.

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Incorrect syntax near '.' meraj ADO.NET 6 February 27th, 2012 01:01 AM
Incorrect syntax near '!' sinapra Classic ASP Databases 8 August 25th, 2004 02:15 AM
Incorrect syntax near '`' Hez Classic ASP Databases 3 August 5th, 2004 08:13 AM
Incorrect syntax...... Adam H-W Classic ASP Databases 8 June 21st, 2004 11:14 AM
Incorrect SQL Syntax?! ckudrna Access VBA 1 June 5th, 2003 03:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.