473,416 Members | 1,850 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Auto Increment problem

Tom
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.");
}
%>
Nov 12 '05 #1
2 12691
You need to specify the field names corresponding to the values you
are inserting. Here's the general format of the INSERT INTO
statement:

INSERT INTO target [(field1[, field2[, ...]])]
VALUES (value1[, value2[, ...])

Add the field names in the same order as the values omitting the auto
increment field and you should be in business.

Rick Collard
www.msc-lims.com

On 16 Oct 2003 12:45:09 -0700, th*************@Q1Labs.com (Tom) wrote:
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.");
}
%>


Nov 12 '05 #2
Tom
Hi,

Thanks for taking the time to respond and thanks for your help. I
added the specific fields to my SQLString and it worked like a charm.

Have a good day,

Tom
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Yan Roosens | last post by:
Hello all, I'm a total newbie with SQL Server 2000 and I have a little problem when moving a database form Access 2000 to SQL Server 2000. In the Access database, each table has an...
0
by: Santosh | last post by:
Hi, I have a requirement in which I need to create an auto increment column in a file which will be unique. The following is what I am trying to do. 1) I need to use DDS to define the file 2)...
6
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I...
1
by: John | last post by:
Hi I am using Application.ProductVersion.ToString to get the app build number but the problem is that it does not auto increment. I have even replaced the content of AssemblyInfo.vb file from a...
5
by: Paulovič Michal | last post by:
hi all, I have problem with SERIAL field type (or sequence functionality). I have table with three columns - ID, IDS, NAME. I want auto-increment IDS grouped by ID. Example: 1, 1, Ferdo 1, 2,...
5
by: vul | last post by:
In VB6 there is Auto Increment check box in Project Properties, which allow you have a new version every time you compile the project. Is there any easy way to have this feature in VB 2005? Some...
2
by: john | last post by:
Is it true that if I split my access database in backend and frontend and I implement custom auto increment for the ID fields, that my database is ready to be used in a multi-user environment? I...
13
by: S.Dickson | last post by:
I had an access database that i use as an ordering system. I have a form for entering customer details. When i add a new customer on the form the customer number is an auto number that appears when...
0
chumlyumly
by: chumlyumly | last post by:
Hello scripters - OS: Mac OSX Language: PHP w/ MySQL database I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.