JJ9867
04-19-2003, 08:49 PM
Hi I'm new at Asp and last weekend I put together a page to take form input and put it into an access database. After solving a few simple errors I hit a brick wall.
The error message is:
Error Type:
Microsoft JET Database Engine (0x80040E14)
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
/test2.asp, line 75
The code for this is:
<%@ LANGUAGE = JScript %>
<html>
<head>
<title>The Asp Test Page</title>
</head>
<body>
<%
// declare variables
var name;
var bname;
var phone;
var email;
var address;
var city;
var state;
var zip;
var key = 2;
//initialize variables
name = Request.Form("name");
bname = Request.Form("bname");
phone = "(" + Request.Form("phonea") + ") " + Request.Form("phoneb") + "-" + Request.Form("phonec");
if (Request.Form("email") == null)
{
email = "None";
}
else
{
email = Request.Form("email");
}
address = Request.Form("address");
city = Request.Form("city");
state = Request.Form("state");
zip = Request.Form("zip");
// Create database access variables
var oConn;
var oRs;
var filePath;
// Map the database Path
filePath = Server.MapPath("test.mdb");
// create the connection
oConn = Server.CreateObject("ADODB.Connection");
oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath);
oRs = oConn.Execute("SELECT CustomerId From customers");
if (oRs.eof)
{
key = 0;
}
else
{
var temp;
var index = 0;
while (!oRs.eof)
{
if(oRs(0) > key){
key = oRs(0);
}
oRs.MoveNext();
}
}
key++;
//Populate the DataBase
oConn.Execute("INSERT INTO customers (CustomerId, Name, CompanyName, PhoneNumber, EmailAddress, Address, City, State, ZipCode) values ('"& key &"', '"& name &"', '"& bname &"', '"& phone &"', '"& email &"', '"& address &"', '"& city &"', '"& state &"', '"& zip &"')");
oConn.Close;
oConn = 0;
%>
Thank you for submitting the information to whatever this database is.<br>
Click here to see the database:<a href="main.asp">The main database</a>
</body>
</html>
I'm running IIS on a windows xp machine.
Any advice would be great,
Thanks
JJ
The error message is:
Error Type:
Microsoft JET Database Engine (0x80040E14)
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
/test2.asp, line 75
The code for this is:
<%@ LANGUAGE = JScript %>
<html>
<head>
<title>The Asp Test Page</title>
</head>
<body>
<%
// declare variables
var name;
var bname;
var phone;
var email;
var address;
var city;
var state;
var zip;
var key = 2;
//initialize variables
name = Request.Form("name");
bname = Request.Form("bname");
phone = "(" + Request.Form("phonea") + ") " + Request.Form("phoneb") + "-" + Request.Form("phonec");
if (Request.Form("email") == null)
{
email = "None";
}
else
{
email = Request.Form("email");
}
address = Request.Form("address");
city = Request.Form("city");
state = Request.Form("state");
zip = Request.Form("zip");
// Create database access variables
var oConn;
var oRs;
var filePath;
// Map the database Path
filePath = Server.MapPath("test.mdb");
// create the connection
oConn = Server.CreateObject("ADODB.Connection");
oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath);
oRs = oConn.Execute("SELECT CustomerId From customers");
if (oRs.eof)
{
key = 0;
}
else
{
var temp;
var index = 0;
while (!oRs.eof)
{
if(oRs(0) > key){
key = oRs(0);
}
oRs.MoveNext();
}
}
key++;
//Populate the DataBase
oConn.Execute("INSERT INTO customers (CustomerId, Name, CompanyName, PhoneNumber, EmailAddress, Address, City, State, ZipCode) values ('"& key &"', '"& name &"', '"& bname &"', '"& phone &"', '"& email &"', '"& address &"', '"& city &"', '"& state &"', '"& zip &"')");
oConn.Close;
oConn = 0;
%>
Thank you for submitting the information to whatever this database is.<br>
Click here to see the database:<a href="main.asp">The main database</a>
</body>
</html>
I'm running IIS on a windows xp machine.
Any advice would be great,
Thanks
JJ