Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · Web Hosting Plans · Faisal Khan's Blog · Contact
Forums : ASP : ADO/ODBC : Syntax error in INSERT INTO statement. Signup · Login
Author Thread
Syntax error in INSERT INTO statement.
Posted in tutorial: Inserting Form content into Database with ASP
·  basi
User
Joined: 12 Dec 2004
Total Posts: 3
Syntax error in INSERT INTO statement.
Posted: 12 Dec 2004
<%@ LANGUAGE="VBSCRIPT" %>
<% Option Explicit %>
<!--#include file="adovbs.inc"-->



<%

'Declaring variables
Dim name, email,password, address, age,member, data_source, con, insert

' A Function to check if some field entered by user is empty
Function ChkString(string)
If string = "" Then string = " "
ChkString = Replace(string, "'", "''")
End Function

' Receiving values from Form
name = ChkString(Request.Form("txtname"))
age = ChkString(Request.Form("txtage"))
password = ChkString(int(rnd*10))
address = ChkString(Request.Form("txtpost"))
email = ChkString(Request.Form("txtmail"))
member = ChkString(int(rnd*10))
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &_
Server.MapPath("../source/members.mdb")
insert = "INSERT INTO tblmembers (Name, Age, Password, Address, E-mail_Address, Member_Number) values ('" & name & "', '" & age & "', '" & password & "', '" & address & "', '" & email & "', '" & member & "')"

' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open data_source
con.Execute insert
' Done. Close the connection
con.Close
Set con = Nothing

%>

<HTML>
<HEAD>
<title>Confirmation</title>
</HEAD>
<BODY background ="../images/dream.jpg">
<font color ="white"><H3>You have Successfully Been Added to our Member List</H3></font>
<TABLE WIDTH=600 BORDER=0>
<TR>
<font face="batang" color ="white"><p>Your Details are:<p/></font>
<font face="batang" color ="white"><p> Name <% Response.Write name %> </p></font>
<font face="batang" color ="white"><p>Age <%Response.Write age %></p></font>

</BODY>
</HTML>
·  netboffin
User
Joined: 4 Jan 2005
Total Posts: 1
Syntax error in INSERT INTO statement.
Posted: 4 Jan 2005
Hi Sebastian,
You have the reserved word password as one of your fields. If you change the fieldname in your database and change your sql accordingly it should fix the problem.


Michael

Users Who Have Visited This Thread In Last 24 Hours
6 Visitors

Login
UserName Or Email Address:       Password:       Auto-Login:    
· Create New User Account
· Send Forgotten Password by Email
 
© 1999 - 2009 Stardeveloper.com, All Rights Reserved.