I am trying to store information into a table that has an auto
increment field. There is currently no data in the table. Using the
code below I cannot insert data into the table. I get an error telling
me that "Number of query values and destination fields are not the
same."
If I add a value for the auto increment field to the SQL String the
data is entered into the table with no problems but obviously the auto
increment field now contains the value I sent to it and not an
incremented number.
Why doesn't the field auto increment when I insert the information for
the rest of the fields? Do I have to initialize the auto increment
number in some way? Please help.
Thanks in advance,
Tom
<% @LANGUAGE="JScript" %>
<!--#include file="adojavas.inc"-->
<%
var dbConnection = Server.CreateObject("ADODB.Connection");
dbConnection.ConnectionTimeout = 30;
dbConnection.Provider="Microsoft.Jet.OLEDB.4.0";
dbConnection.Open("C://Documents and
Settings//thomas.mccardle//Work//data//qvquest.mdb");
if (dbConnection.State == "adStateClosed") {
Response.Write("The database is not available.");
} else {
var SQLString = "INSERT INTO CompanyProfile VALUES ('"
+ Request.Form("CompName") + "', '"
+ Request.Form("Contact") + "', '"
+ Request.Form("Addr") + "', '"
+ Request.Form("City") + "', '"
+ Request.Form("State") + "', '"
+ Request.Form("Zip") + "', '"
+ Request.Form("Tel") + "', '"
+ Request.Form("Email") + "')";
dbConnection.Execute(SQLString);
dbConnection.Close();
Response.Write("The entry has been successfully added.");
}
%>