Generating Particular Autonumber
Ive got a table in an access database and I want to generate my own autonumber
based on the number of records in the table. Code:
Ive got a table in an access database and I want to generate my own autonumber
based on the number of records 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?
View Replies View RelatedI'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
A portion of the asp for our site looks like this: Code:
insert = "INSERT INTO Students VALUES ( '" & _
(????)
CStr ( Request ("UserName") ) & "','" & _
CStr ( Request ("Password") ) & "','" & _
CStr ( Request ("Email") ) & "','" & _
CStr ( Request ("Country") ) & "','" & _
CStr ( Request ("DOB") ) & "','" & _
Date() & "@" & Time() & "','" & _
Date() & "' )"
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!
How can i get the autonumber(primary key value) from the specific rows when i just insert it.Example
i just insert the member information.
sql="INSERT IMTO register(user,password,address) VALUES (shujuan,841218,singapore)"
so how can i get the primarykey for this row after i just create it.
var SQLString = "INSERT INTO table VALUES( '' ,'" + Request.Form("name") + "','"
+ strAlpha + "','', '"
+ Request.Form("email") + "', '"
+ Request.Form("userid") + "')";
dbConnection.Execute(SQLString);
This is jscript inserting into access2000. My table looks like this:
id (autonumber)
name
date
email
userid
Its the first field that causing my problems, I get a data type mismatch error. How do I insert with an auto incremented field?
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:
View Replies View RelatedI 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.
View Replies View RelatedI 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:
View Replies View RelatedOK, 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.
Is there any way to format the autonumber or change it in Microsoft Access?
View Replies View RelatedI 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.
View Replies View RelatedWhy 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>
Why do I keep getting a type mismatch on this
Set cnn1 = Server.CreateObject("ADODB.Connection")
openStr = "driver={Microsoft Access Driver (*.mdb)};" & _
"dbq=" & Server.MapPath("fpdb/images.mdb")
cnn1.Open openStr,"",""
sql = "SELECT * FROM gallery"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, cnn1, adOpenDynamic, adLockPessimistic, adCmdText
temp = cINT(request("pic"))
rs.Find "id = " & temp
I've tried multiple variations.
I have 3 tables and they are linked with each other.
table 1 (ID, Title)
table 2 (QuestionID, ID, Question)
table 3 (AnswerID, QuestionID, Answer)
the problem is that ..
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 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:
View Replies View RelatedI have a line of code in my script that looks like this:
Set User = objDBCon.Execute("SELECT * FROM tblsUsers WHERE ID = '" & request.form("user") & "'")
This gives me an error of data type not the same. Anyone know what the problem might be?
I am not an expert in ASP but i am trying to generate a page in which i am able to generate an ID for any one viewing that page or entering the data.
View Replies View RelatedI wanted to know that is there someway in ASP that I can generate images on-the-fly without using ne 3rd party component?? Like its possible in CGI-Perl to generate ne type of image on-the-fly, is there a way 2 that in ASP? OK, if the 3rd party components r the only way, then r there ne free ones available?
View Replies View RelatedDoes anyone know how to generate a variable NAME?
I’m thinking of something along the ground of:
<%
myvar=�hello�
(“stuff�&myvar) = request.form(myothervar)
%>
I need to generate some reports with graphical charts (line, pie, bar and polar). I want to generate those charts which represent database values. Hope I have to use a 3rd party control for this.
View Replies View RelatedI've been surfing the web and this forum for methods to upload images through a form in a browser. I've come up with a few results, e.g. Dundas free upload component.
Besides that I've got the free product from ServerObjects.com to check the ImageSize and found some other non-component method to check the Image dimensions at: LearnASP.com.
Users should be enabled to upload a thumb for their profile. Since I can't expect each user to be a computer literate they might upload an image which is a bit too big. Are their free methods with ASP to reduce those images in size? I'm simply using ASP here with IIS. For now I can only give them an error stating that their image is too big.
A second matter might be a photogallery where there's bigger images and thumbnails. Right now I'm using Irfanview/Ifranview to quickly make thumbs for each regular image. Like with the example above it would be ideal if this can be automized as well, since users should be enabled to put up some small photogallery as well.
I know there's some fancy expensive methods to achieve this, but usually they offer loads more and all I need is something to crop or resize (resizing is best).
I'm looking for a code or a component that will enable me to generate images on the fly, through my ASP code.
For example:
Retrieve some textual data from a database and make an image out of it.
OR
Combine text and an existing image into one new image.
OR
Read an HTML file that contains text and image and generate an image from it.
I've found programs that do it (like ABC Amber Text2Image Converter), but I fail to make it work through a code and not through a software console.
I have been asked to produce reports which will be triggered and generated automatically via scheduled tasks against data in SQL SERVER.
The reports will be generated as CSV's to provide compatibility with Excel.
The reports will then e-mailed as attatchments to an agreed list of recipients.
This all has to be done with the use of ASP and SQL Server.
Can anyone advise on how the prolem should be approached?
How can I generate screenshots (.jpg) from a .flv file using asp?
View Replies View RelatedI'm generating excel spreadsheets online with many manufacturers. One
particular manufacturer has 5000 more records than the next highest. When I
query for that manuf the table does not form. Just plain text. It doesn't
time out. Just doesn't form properly.
Is there a cache or setting I need to increase to get this much data?
Does anyone know of any freely usable code that helps automate the
process of generating RTF files from ASP (particularly generating the
code needed for tables)?
Basically I have a site where the administrator adds new students to a college system. This code just adds a new student to the database. When they are added a username is generated by taking the first letter of the forename and the first from the surname and joining them to the date.
(ie, James Brown would generate JB2005) Obviously some people will have the same initials so i'm trying to get all the records from the student table in my database that has the first two letters as the student I'm trying to add and adding the value of the count of that recordset before the date of the new students initials. (ie, if Jane Bennett was added the username would be JB12005 because there is already a user with the initials JB in the database)
At the moment if i add a new member to the database, the fields are populated but the count of the recordset is not added so I end up with duplicate usernames. I'm not sure if the recordset is even being filled or whether the recordcount is not working. Code: