How Do I Retrieve The Key Of An Inserted Record
I have to tables related to eachother,
like for example
an Emlpoyee table which has an Auto Number as primary key and as the ID of the employee.
And Employee_Phones which has 2 fields the Employee's ID and the phone number field.
when I insert a new record in the Employee table, I want to insert multiple records related to it in the Employee_Phones table.
After inserting a record in Employee table I want to retrieve the ID, then use that ID to insert other records in Employee_Phones table.
Is there a command of function to return the ID of the inserted record, Or do I have to query the database again? I've loked for a function or a method but I didn't find any?
View Replies
ADVERTISEMENT
I have a form to submit a record to a database and immediately after it's submitted I want to send an email with a link to that record. How can I retrieve it's ID (which is an autonumber) from the db to write it into the querystring of the link?
View Replies
View Related
The problem is that all the tuts I find on hits do the insert and connection so differently I am lost!
My code so far:
Code:
Dim rsBOR, inBOR, insSQL, newID
Set inBOR = Server.CreateObject("ADODB.Connection")
Set rsBOR = Server.CreateObject("ADODB.Recordset")
inBOR.Open Application("strConn")
insSQL = "insert into Main (EventName, .., RegionID) values ('"& strEventName & "',..,'" & RegionID & "')"
inBOR.Execute insSQL
' Retrive the ID
newID = inBOR("EventID")
Response.Write "The Event has been added to the database"
inBOR.Close
But it just doesn't like it!
Any ideas on how I should go about this?
View Replies
View Related
I'm using mySQL and wanted to get the ID of the record that I have just inserted in to the table (sentmessages). There is a function in mySQL that appears to be able to perform this task but I am not having any luck in getting it to work.
Anybody else tried, successfully or not, to use this ? The function is called LAST_INSERT_ID() and I have tried to implement it as follows :
strLastID = objConn.Execute("SELECT LAST_INSERT_ID() FROM sentmessages") .
View Replies
View Related
iwana code with aspwho can help me?think that i make a interface which with sql sttement lsted all the records in the one table.another one at that time inserted a new record.so iwanna have a cod that listedrecords (when that record was inserted) and i see all the record(cotain the new record) again.plz help me and show me a code.my mail is kianoosh_ardavan@yahoo.com
View Replies
View Related
I am using ASP and SQL server 2000.
I insert reocrd using Insert query.
I want to get value of last inserted record in ASP for SQL server.
How i can get it?
View Replies
View Related
I'm using SQL to pull records from our db but my query is returning all results in the db table and I only want the most recent entry. There is a date_time column in the format MMDDYYYY HH:MM:SS and I'm using that to order by then writing only the first line which works, but is very slow since there are a lot of records to go through.
What I'm looking for is a way to only retrieve that most recent record instead of pulling them all, then ordering them. Would I be able to use the MAX function for something like this? Does MAX work with a date_time field?
View Replies
View Related
In my Access database I have multiple images for some of the records. What is the best way to retrieve and display the multiple images. I am storing the images in a folder and only the path in the DB. Some of them have just 1 image, some 2, some 3 and so on. I have the record ID # and the image name same, for eg. if the record id is R01 then the image name would be R01.jpg if there is only 1 image otherwise R01a.jpg, R01b.jpg, R01c.jpg etc. Is there any way I can open the folder and check for the name and list the image file names as a link to display the images if the ID name and image name matches.
View Replies
View Related
is there any way I retrieve record identity from data that i just insert in...
View Replies
View Related
I have 2 tables Table_A and Table_B are linked together by TaID
Table_A
TaID - autonumber
Name
Address
Table_B
TbID - autonumber
TaID
Comments
here is my asp page
-------------------------
<%@ Language="VBScript" %>
<!-- #include file="connectionstring.asp" -->
<%
'declare variables
DIM ......
'Assign Variables
.......
Set Conn = Server.CreateObject("ADODB.Connection")
'database connection
Conn.provider = provider
Conn.ConnectionString = dbasepath
Conn.Open
'Sql statement to insert the data
sql = "insert into Table_A ( Name, Address) values (...*data from form*...)
' execute it
Conn.Execute(sql)
Response.Write "Data successfully inserted!"
Conn.Close
Set Conn = Nothing
--------------------------------------------
my question is I also need to insert the data to Table_B, but before that, I want to retrieve the Table_A.TaID first.
so if i do "select TaID from Table_A" and execute the sql how do I assign just the LAST record of TaID and assign to temp variable?
Do I allow to do that? if so, where should I put in the code above?
View Replies
View Related
I have an oracle database that I am submitting a form to. In the database I have setup a trigger to insert a casenumber everytime a form is inserted into the database. After they submit the form I then want to display to them the casenumber so they can check the status later. My problem is returning the correct casenumber to the user. Currently I am returning the max value from the casnumber column, but I think that may cause problems.It is working right now and gives me the correct value, but will I run into problems if 2 people submit a form at the same time? If you don't think this will work, what would you suggest I do? Is there anyway to return the value from my trigger?
View Replies
View Related
Im using a ASP and MS Access 2000 database. What im trying to do is: I insert a row into a table, in that table is a field that auto increments. after I insert this row I want to immediately after that be able to retrieve the value of the column containing the auto increment and hold it in a variable so i can use it for other things.
can anyone help me with this? I have been messing around with SQl cursors but cant seem to get it to work right.
View Replies
View Related
I have a form where people from around the world will enter their address. As you know, addresses from around the globe vary so darn much. I thought that instead of a form with text boxes for such things as city, zip, street 1, street 2, etc., I could use a text-area. That being said, if someone entered in an address in a text box such as this:
Joe User
121 E 209th
Euclid Ohio
44123
United States
Could I take that and on the insertion into a database insert a <br /> where appropriate?
View Replies
View Related
That error is this:
ADODB.Recordset error '800a0cc1'
Item cannot be found in the collection corresponding to the requested name or ordinal.
/noticias/indexnot.asp, line 45
In line 45 I have this stretch of the complete code below.
RS5_Tema(Aux) = RS5("auxcategorias")
The problems in codigo had started later that I added this code more. Code:
View Replies
View Related
I don't know if anyone has encountered this before. I've written ASP code to insert, update and delete records from Access and SQL Server tables before but this is the first time I face this issue -
I have a form that inserts data into an Access table. For a few of the fields, commas are getting inserted into the table. If the field is left blank, there is a comma inserted. If we enter data in the field, the comma is appended to the field value (eg: smith, )
The only thing different that i'm doing here from what I've done before is I'm inserting a larger number of fields into the table - 117 fields!!
Do you think the insert statement hasn't been written correctly?
View Replies
View Related
When I insert a record into my database, I don't insert the ID field because it's an autonumber and I want the database to generate it right?
Here's my question: Is there a way to have the recordset return that ID, or some other way of getting it with out making another recordset to grab the ID of the record that I just inserted?
View Replies
View Related
when I ourput data from Access, numbers bigger than 999 are shown with letter "B" inserted into the 4th position left to the coma. (in my w2k regional settings I have the decimal dot separator set to "." and digit group separater set to nothing. In Access the number are shown with "." as decimal separator, but for some reason ASP used "," instead)
Say, 3000,00 is shown as 3B 000,00 Why and how do I sort this out?
View Replies
View Related
i have a problem with my asp code...when i run a query, i insert the results on a temporary table...everything works fine except when i try to load the result page, it doesnt not display the recordset...
i need to press F5 always so that the page will be refreshed to show all records in the table.. how can I retrieved all inserted records in the temporary table without reloading the page?? below is my result page... Code:
View Replies
View Related
I'm UPDATING a value into an Access text field from a page but I can't get it to do the UPDATE without adding a leading space to the value??
This is a problem because I have another page where a user can search the entries, but when they do a search by this particular criteria, it returns no entries (ie. Search good_bad by "Positive" returns no results, but Search good_bad by " Positive" will return the proper results).
The value is coming from a option select box. It seems to only be a problem doing an UPDATE using a value from a select box as I'm using the EXACT same code to do an INSERT where the value comes from an INPUT box and it inserts with no leading space?? Code:
View Replies
View Related
Without writing a bible on what I'm trying to do I'll see if someone
can answer a quick question.
I have a form that the user writes a value in a test field. I need to
put a hidden value that will take the same number the user inputs and
insert it in a form.
Basically, I need ...
<input name="hdndkqty" type="hidden" id="hdndkqty" value = ??? />
the value of the hidden field to = <input name="num" type="text"
id="num2" />
View Replies
View Related
I'm getting this error message: Error Type:
Microsoft JET Database Engine (0x80004005)
You cannot add or change a record because a related record is required in table 'employees'. Code:
View Replies
View Related
sql = "UPDATE Marknad SET" _
& " Typ ='" & Typ & "'" _
& ", Modell ='" & Modell & "'" _
& ", Arsmodell ='" & Arsmodell & "'" _
& ", Beskrivning ='" & Beskrivning & "'" _
& ", Stad ='" & Stad & "'" _
& ", Prisidé ='" & Priside & "'" _
& ", Fornamn ='" & Fornamn & "'" _
& ", Efternamn ='" & Efternamn & "'" _
& ", Telefon ='" & Telefon & "'" _
& ", Epost ='" & Epost & "'" _
& ", Datum ='" & Datum & "'" _
& " WHERE (((Marknad.Annonsnr)=" & Request.QueryString("id") & "))"
DatabaseConnection.Execute sql
---
Above does work as I want it to do BUT it inserts 1/8/2006 instead of 8/1/2006 as it should!
The best thing would be to exclude the date from updating at all, but when taking away the line:
& ", Datum ='" & Datum & "'" _
It gives an error... how do I solve this?
I forgot, you might want to see this:
Datum = date
View Replies
View Related
I have an insert record form that posts fine to a db which automatically creates an ID how could I get the next page to do a preview using the ID just created by the DB to go to the right record?
View Replies
View Related
I have a .asp page which lists a date, then a bunch of record lines for data that falls within that date, then the next date and it's bunch of data record lines. e.g.
Ship Date: 04/06/04
Data xxxxxxxxxxxxxxxxxxxxx
Data xxxxxxxxxxxxxxxxxxxxx
Data xxxxxxxxxxxxxxxxxxxxx
Data xxxxxxxxxxxxxxxxxxxxx
Ship Date: 11/07/04
Data xxxxxxxxxxxxxxxxxxxxx
Data xxxxxxxxxxxxxxxxxxxxx
Data xxxxxxxxxxxxxxxxxxxxx
What I want is:
Ship Date: 04/06/04
1: Data xxxxxxxxxxxxxxxxxxxxx
2: Data xxxxxxxxxxxxxxxxxxxxx
3: Data xxxxxxxxxxxxxxxxxxxxx
4: Data xxxxxxxxxxxxxxxxxxxxx
Ship Date: 11/07/04
1: Data xxxxxxxxxxxxxxxxxxxxx
2: Data xxxxxxxxxxxxxxxxxxxxx
3: Data xxxxxxxxxxxxxxxxxxxxx
How can I get these numbers printed againsts the records ?
View Replies
View Related
How to value in drop down value from mysql database ..
Technical Languages:
Front ENd: XHTML
Validation: JavaScript
Server Scripting: ASP
Server:IIS
Database: MySQL
View Replies
View Related
I have two tables having similiar columns ( i had to do this to compare the values given to me, because both the table data came from different sources)
The tables named are
OFFICERS
token
full_name
division
EMPLOYEE
token
full_name
division
Now the table EMPLOYEE contains more than 5000 records and the table OFFICERS contains around 2400 records which are already present in the EMPLOYEE table.
Now I want to build a query that will return me all the records in the EMPLOYEE table that are not present in the OFFICERS table. The criteria for comparing 'full_name'. so the query should return me 2600 records that are not present in the OFFICERS TABLE.
I tried doing this
" SELECT DISTINCT EMPLOYEE.full_name,EMPLOYEE.token,FROM EMPLOYEE,OFFICERS WHERE EMPLOYEE.full_name<> OFFICERS.full_name"
But this query returns me records that is not present in the OFFICERS table as well as some more 1000 records which are present in both tables.
thanks a lot
View Replies
View Related
I want to have a form where there is a textfield and a Browse... button to the right of it. I want the user to be able to press the Browse... button and select a file and then that filename be returned to the textfield.
I don't want it to upload it or anything like that...I just want to know the filename that the user has selected. Also, when the user presses the Browse... button, I want it to automatically go to a certain place.
View Replies
View Related
I write the code as floowing to check the file nam before submit , but it show nothing when i click submit button. Code:
View Replies
View Related
if i have 08/21/2007 11:07:27 AM in the database..
what should i do to just show it out as 08/21/2007 ?
View Replies
View Related
I am trying to access the following site with an asp page. I am just starting out with XML
URL
This is my stats page for battlefield Vietnam. I have managed to get a local verison to work if I save the source code of the page above as an xml file on my server, and I use the following code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% Option Explicit %>
<%
Dim xmlDoc, root
Dim success, player, strData, online ,rank, rp, score, kills, deaths, fttk, kdr
Dim dpm, ftpm, mppr, medals, gold, silver, bronze, rounds
Set xmlDoc = server.CreateObject("msxml2.DOMDocument")
'
What I can't figure out is how to access the data from the external site.
View Replies
View Related
This is my code can you fix it if it have an error
<select>
<%
set rs = Server.CreateObject("ADODB.Recordset")
strSQL = "select cat from events"
rs.ActiveConnection = conn
rs.open strSQL
if not (rs.eof or rs.bof) then
for i = 0 to rs.eof
response.write("<option>" + rs(i) + "</option>")
next
end if
%>
</select>
View Replies
View Related
I know that you can retrieve data from a form using
Request.Form("name"), but how do you retrieve a file?
View Replies
View Related
how can i retrieve information on a form page that once previously submitted by the user so that when the user goes back to that form page it will remember what they inputted instead of having them to retype it again? do i have to use session? can somebody please help me... what would be the easiest and most efficient for a newbie to tackle this problem?
View Replies
View Related