OK, I realize this is a subject that almost every developer would encounter, so I understand the answer is probably out there somewhere. Suffice it to say that I have been looking, both in this forum and on google, found many SQL server answers, and one for Access, which I have tried with no success. See the following: Code:
sql = "INSERT into someTable(IntColumn) values (" & fakeValue & ") SELECT @@IDENTITY" set rs = conn.execute(sql) response.write "New ID was " & rs(0)
This results in a JET database error, Missing semicolon at end of SQL statement. I tried adding it after the close paren, after the select @@identity, and after both, with the same error.
I insert the question in the correct place which is related to the table 1 but when it come to insert the answer for that specific question id didn't work .. it always take the first question in the table Code:
I've searched the net but I couldn't find any SQL code on how to insert an autonumber column into an access database and table. Can anyone include the code?
I'm creating a basic ASP guest book, keeping my guest book entries in a Microsoft Access database, and using ADO to access it. My problem is that I am using the autonumbered ID field to split my guestbook into pages of 10 entries. It works for the most part, but if I delete an entry, a gap is left in the records and I end up 9 entries instead of 10 on that page. Basically I need a better way of sorting this out - I thought of SELECTing all the records into an array first and then working from that, but I can't get array to be dynamic enough in VBscript
It just inserts a new record into the db. What we did was add an autonumber field to the db, but now it won't update.
We know why - because it needs a value for every category in the db - but we don't know how to code it so it will update the db correctly. So, if anyone could help me with the (????) line in the coding so it will correctly update, that would be perfect!
What is the best way of using an AutoNumber system on an SQL server?I've been used to using Microsoft DBs for my online apps and have now upgraded to using Microsoft SQL server.
I want to be able to insert a new record into the database not such a problem but I want each record to have a unique identity no eg. NewsID. I know that you can do a lookup of the MAX number on insertion but if two people are inserting at the same time this may cause problems with duplication.
I use (something like) following code to add new records to a database, but it doesn't work!!! I need to know the value of an AutoNumber-field when I add the record. Why doesn't it work and how can I make it work? I think it should be easy, but I can't figure it out! Code:
I have a page that does an insert into a table in an Access DB which has an autonumber primary key field. Following this insert I need to be able to get the ID that was generated. If I were using SQL Server I would simply return fetch @@IDENTITY from a stored procedure for example.
Does anyone here know of something similar I can use in Access to be able to get that ID? I tried just using a SELECT query with all the information I had just inserted but it comes up empty unless I put it in a separate request (i.e. redirect to a new page passing all the info through the querystring and then building the query on the redirect page...which is a huge pain and takes FOREVER to run.
I have a form that is filled out and put into an Access database. The id field is Autonumber.
What I would like to do is also insert this data (or some of it) either into another database or another table, but I would like the created AutoNumber to be a part of this data. Is there any way to get this number immediatly after insertion?
I'm trying to write the code for an autonumber to go in to a text field when the page is open. I had it working in access but of course it won't work in asp. The format has to be for example: PBC-1200.
I have an Access database that uses an autonumber for the primary key. I hv app. 110 items in the table, and yet when I add a new item, it autonumbers as 534097 or some ridiculously long number.
How can I get it to go back to a smaller number without removing/trashing existing ID fields?
I have a recordset with two three fields. One is an autonumber field called ID , one is a text field called Name and the last is a date/time field called DateEntered. How can I programatically determine the autonumber field ? Code:
I am using Ms Access database and I have set 3 digits (e.g. 000) for an autonumber field of my table.Its working fine in Access and incrementing automatically like this (001, 002, 003 ...), but when I call the data on a web page using ASP its displaying these numbers like this (1, 2, 3, 4 ...) I dont understand why is it not displaying the numbers as it is in the table.
Why won't this code work - the "id" fields are autonumbers
Code:
<select size="1" name="Agent" tabindex=""> <option value="Select">Select Owner</option> <% x = rs("id") Do While NOT rs2.eof y = rs2("id") Response.Write "<option value='" & rs2("id") & "'" If x = y Then Response.Write " Selected" End If Response.Write " >" & rs2("first") & " " & rs2("last") & "</option>" & vbCrlf rs2.MoveNext Loop %> </select>
I want to take the last record in my database and display it on my ASP program. From my understanding, when last record + 1, it will be autonumber right. It's like generaing the autonumber for invoice number.
For easier view, my last record is 21. So I want that 21 appear in my ASP system as 22. Is anyone can give me the idea how to make it?
I'm writing a database admin page in ASP. I had it adding records correctly. Then I added an autonumber field ("ID") to the table, and it stopped working. The sql I'm using is Code:
Our graphic designer has just finished redeveloping our website. On the site, we use SSL to secure the area where a user enters their personal information to order items from us. (we do not do many transactions - maybe 1 per day...) We are a log home mfg company so they would only order plan books, maybe a video etc...
When the user clicks "Submit Order", we want to encrypt each data item (because of new legislation governing customer personal info etc...) and write a record to an access db. From here it will be imported into our Customer DB leads database...
I do not use ASP but program in VB 6 and Access 2000. ASP looks similiar in many ways...
Does someone have a good ASP script for encrypting data? And, if so, is it fairly strong encryption?
Also, is there any trick to writing an "insert" SQL script in ASP or is it exactly the same as I would do in VB or Access? Maybe someone has an "insert" script handy they could pass along including the command to actually execute it?
that's shortly the way i'm inserting new records. using mysql and asp functions.
The prob is that inserting only one record every time. if i got data for 3 records how can i make it at once to add 3 new records in some given order into the db
What is the best way to see if a record has inserted correctly into the datase in ASP? Also, how to tell the user what the error is. I am inserting like this with the ADO command object: Dim sInsert, objCmd set objCmd = Server.CreateObject("ADODB.Command") sInsert = "sp_ADS_Insert_Driver_General_Data " on error resume next With objCmd .ActiveConnection = oConnEnergy .CommandText = sInsert .CommandType = adCmdStoredProc .Execute , , adExecuteNoRecords
Application X has three screens. The user captures information on screen one and then clicks a navigation button to go onto screen two.He does the same on screen three. At the bottom of screen three is a submit button. When this button is clicked the system does some calculations with the information that is supplied and then uploads all the info that was captured on the screens to the database.
Should the data be uploaded to the database all on one go when the user clicks the submit button or should it be uploaded after each screen - ie when the user clicks the button on Screen 1 the data is uploaded to the database and then screen two is displayed.
I have a column call UserDate and it's properties are this : varchar(50) . I have a function which updates the column with todays date. for some reason, if I manualy give the value to be inserted a value of '10/10/2006' or use date() it inserts a value of 0 if I give a value of 4 to be inserted it works?
I have been working on a project for 2 days and this is the last piece to get it to work, can anyone point out where I'm going wrong. P.S I have tried giving the colum a date format but unfotunately the format is american and I need it in english to compare with something else I'm working on.