472,371 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 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 12521
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
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

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.