Last Inserted Record ID
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
ADVERTISEMENT
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 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
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 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
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
I want to download record set from my SQL database as csv format but in ZIP file .I can download as a csv file now ..But i can't put that in zip file and download.
View Replies
View Related
how to deal with multiple recordsets on the same page?
It's gotta be something small and clear so I could understand.
Somewhere I've read that multiple recordsets are not allowed when using Microsoft Access Database?
View Replies
View Related
I am looking to
have some sort of SQL Trigger maybe? I have a field called 'dateActivated' and 'isActive'I'm looking to somehow say when dateActivated + 6 months then set isActive = false. I want this to
be automatic. I am using ASP/VBScript if this somehow matters.
View Replies
View Related
I have a form on an asp page which is used to add additional users to
the DB, i.e. adding a UserID (PK on table), Password & Email.
The companies are allowed a max of 3 users. If the company only has
the default 1 user and wishes to add another 1 or 2, then the form
displays the current user details, not in text boxes as this is not an
adit data form. The additional user/s can be entered into 1/2 rows of
text boxes, user 2 & 3.
If they decide to add 2 new users, how do I add the additional 2
records to my db table on submit ? Code:
View Replies
View Related
i am tryin to run a search on a db and am using a like statement which works fine but i want to select what it finds and also the next 9 records any idea on how to do this
View Replies
View Related
Is there any way to change the following code so that when it's the second last record in the set it doesn't put UNION ALL at the end? Basically, is there a way of saying:
if SecondLastRecord then
I don't know how many records there will be, so I can't count down from 7 or anything.
Code:
View Replies
View Related
Every time I try to ADD a new record from my asp page to SQL table, I got this error:
Microsoft OLE DB Provider for SQL Server (0x80040E2F)
Violation of PRIMARY KEY constraint 'PK_Cancelled_Classes'. Cannot insert duplicate key in object 'Cancelled_Classes'
Here is the Insert statement:
Sql="INSERT INTO Cancelled_Classes (yrtr, cou_id, cancell_date, Message)" sql=sql & " VALUES " sql=sql & "('" & Request.Form("yrtr") & "'," sql=sql & "'" & Request.Form("cou_id") & "'," sql=sql & "'" & Request.Form("cancell_date") & "'," sql=sql & "'" & Request.Form("note") & "')" '
conData.Execute sql
View Replies
View Related
I had a problem that happen once only but i do not want it to repeat
again. It happen when i retrieve data from my database. The process
can't complete and show error 14, Out of string space. I suspect the
recordset object had reach it limit that why it generate that error
message but what can i do to prevent this from happening
View Replies
View Related
I have a siple script where I add a new row in a table which has also a autonumber field. Adding the new row I am trying to get this value of the autonumber field and put it in session, but can not seem to figure out how. I tryed to open a new recordset and pull it out but does not find the record I just added.
View Replies
View Related
The only database connection I have ever made using ASP is to an SQL2000 Server. I was just wondering if someone could provide me with a nice simple script opening a connection and recordset to a MySQL database and providing a valid connection string.
View Replies
View Related
Trying to learn a little asp and am trying to have my form (when the submit button is pressed) put the value in a field in my database. it worked the first time, I typed in the word testing and clicked submit.
now whatever I put in there it creates a new field with the word submit. Can someone tell me what I'm doing wrong here? I'm positive there's something wrong with my code here. Code:
If Request("submit")="Submit Questions" Then
Set questionsubmission=connectionToDatabase.Execute("INSERT INTO kitchen_questions(questions) VALUES('" & database_select("questions") & "')")
End If
View Replies
View Related
I'm looping through a record set and want to treat the first record differently. I've got a counter that I check to determine if its the first iteration through the loop, but I was wondering if there is recordset property that would indicate the record's position in the record set.
View Replies
View Related
now i got all my data in my sql db table (fsearch) . now i want to take the value from the db to display it on the browser in the form of a table .
View Replies
View Related