Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database write AND response

Status
Not open for further replies.

Sajtz

IS-IT--Management
Apr 23, 2002
75
EU
Hi.

I´m constructing a program in Flash (not important), and with this I use asp to write to an access database.

The scenario is this:

I´m sending some registration information to an database. The varables sent is name, date and city.

This works just great, but when I have done this registration I want the asp-page to return the Unique ID the belongs to the registered Person.

In Data:

Name: Peter
Date: 030502
City: Stockholm

Database:

22 Peter 030502 Stockholm

Out Data:

22


Any suggestions?
 
On adding the dating the data retunr the id

rs.AddNew
rs("name")
rs("date") = Now()
rs("city")
rs.Update
id = rs("id")



 
Thnxs for your reply, but I didn´t quite get it since my asp-file looks like this:



<%
Dim DBConn, strDB, strDate,strInsertSQL, strNamn, strENamn, strPersNr,strGata, strPostnr, strStad, strTele, strMobil

strDB = &quot;Driver=Microsoft Access Driver (*.mdb);DBQ=&quot; & Server.MapPath(&quot;SajtzUsers.mdb&quot;)

strDate=CDate(Date)
strNamn=Replace(request(&quot;fornamn&quot;), &quot;'&quot;, &quot;''&quot;)
strENamn=Replace(request(&quot;efternamn&quot;),&quot;'&quot;, &quot;''&quot;)
strPersNr=Replace(request(&quot;personnr&quot;), &quot;'&quot;, &quot;''&quot;)
strGata=Replace(request(&quot;gata&quot;), &quot;'&quot;, &quot;''&quot;)
strPostnr=Replace(request(&quot;postnr&quot;), &quot;'&quot;, &quot;''&quot;)
strStad=Replace(request(&quot;stad&quot;), &quot;'&quot;, &quot;''&quot;)
strTele=Replace(request(&quot;tele&quot;), &quot;'&quot;, &quot;''&quot;)
strMobil=Replace(request(&quot;mobil&quot;), &quot;'&quot;, &quot;''&quot;)

strInsertSQL=&quot;Insert Into users (Datum,ForNamn,EfterNamn,IdNr,Gata, Postnummer,Stad,Tele,Mobil) Values ('&quot; & strDate & &quot;','&quot; & strNamn & &quot;','&quot; & strENamn & &quot;',' &quot; & strPersNr & &quot;','&quot; & strGata &&quot;','&quot; & strPostnr & &quot;','&quot; & strStad &&quot;','&quot; & strTele &&quot;','&quot; & strMobil & &quot;' )&quot;

<% If strNamn <> &quot;&quot; Then
Set DBConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
DBConn.Open strDB
DBConn.execute strInsertSQL
response.write &quot;iSuccess=1&quot;

else
response.write &quot;iFailed=1&quot;
end if %>

DBConn.close
Set DBConn=Nothing

%>



Where does your code fit in?
 
Set DBConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
DBConn.Open strDB
DBConn.execute strInsertSQL
strSQL = &quot;SELECT @@IDENTITY AS NewID&quot;
DBConn.CommandText = strSQL
rsIDENTITY = DBConn.Execute
IDvar = CInt(rsIDENTITY(&quot;NewID&quot;))
DBConn.close
Set DBConn=Nothing

'IDvar contains the ID of the new record.

'This will not work for anyting below Access2000

BDC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top