|
 |
asp_databases thread: Insert AutoNumber(in MSAccess)
Message #1 by "Savonnya D. Rodrigues" <srod@f...> on Mon, 26 Mar 2001 11:10:53 -0800
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_000D_01C0B5E5.6C92C470
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
The code is below. The auto number is in the Software table and I want
the
same number that is in the Software table to be also inserted into the
Installation table. The field in the software table with the autonumber
is
softwareID(Software table) and the field that I want the autonumber
inserted
into is called softwareID(Installation table), and it is not an
autonumber I
just want to insert the autonumber. Please can you help me with this.
'Build the insert string
strSQL1 =3D "Insert into Software (SerialNum, LicenseKeyNum, ProductID,
" &
"ServerApplication, Manufacture, ProductName, Version, Description,
Status,
EquipmentType, Location, Comment) " & "Values('" &
Request.Form("txtSerialNum") & "','" & Request.Form("txtLicenseKeyNum")
&
"','" & Request.Form("txtProductID") & "','" &
Request.Form("txtServerApplication") & "','" &
Request.Form("txtManufacture") & "','" & Request.Form("txtProductName")
&
"','" & Request.Form("txtVersion") & "','" &
Request.Form("txtDescription")
& "','" & Request.Form("txtStatus") & "','" &
Request.Form("txtEquipmentType") & "','" & Request.Form("txtLocation") &
"','" & Request.Form("txtComment") & "')"
strSQL2 =3D "Insert into PurchaseOrder (SerialNum,POComment,PCQuote , "
&
"DateReceived, DateApproved,Cost, MaintenanceAgree, LicenseLocation) " &
"Values('" & Request.Form("txtSerialNum") & "','" &
Request.Form("txtPOComment") & "','" & Request.Form("txtPCQuote") &
"','" &
Request.Form("txtDateReceived") & "','" &
Request.Form("txtDateApproved") &
"','" & Request.Form("txtCost") & "','" &
Request.Form("txtMaintenanceAgree") & "','" &
Request.Form("txtLicenseLocation") & "')"
strSQL3 =3D "Insert into Installation (SoftwareID, SerialNum, UserName ,
" &
"EmpNum, InstalledBy, InstalledDate) " & "Values('" &
Request.Form("txtSoftwareID") & "'" & Request.Form("txtSerialNum") &
"','" &
Request.Form("txtUserName") & "','" & Request.Form("txtEmpNum") & "','"
&
Request.Form("txtInstalledBy") & "','" &
Request.Form("txtInstalledDate") &
"')"
'Create and open the database object
Set objConn =3D Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=3DESS2"
'Create the command object
Set objCmd =3D Server.CreateObject("ADODB.Command")
'Set the command object properties
Set objCmd.ActiveConnection =3D objConn
objCmd.CommandText =3D strSQL1
objCmd.CommandType =3D adCmdText
objCmd.Execute
'Execute the command
objCmd.CommandText =3D strSQL2
objCmd.CommandType =3D adCmdText
objCmd.Execute
'Execute the command
objCmd.CommandText =3D strSQL3
objCmd.CommandType =3D adCmdText
objCmd.Execute
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 27 Mar 2001 17:51:45 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: The code is below. The auto number is in the Software table
: and I want the same number that is in the Software table
: to be also inserted into the Installation table. The field in the
: software table with the autonumber is softwareID(Software table)
: and the field that I want the autonumber inserted into
: is called softwareID(Installation table), and it is not an
: autonumber I just want to insert the autonumber.
: Please can you help me with this.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do it like this:
a) Build SQL string to insert into Software table
b) Get Autonumber
c) Build SQL string to insert into Installation table, using value from (b).
To get the autonumber use code found here (if you're using Access):
http://www.adOpenStatic.com/experiments/fastestautonumber.asp
Cheers
Ken
|
|
 |