I have found a lot of discussion surrounding this, but not quite what I'm trying to do.
Users can create a new record in my dbase. Everything works fine wout problems. What I"m haveing trouble with is after the new record is created, I was to redirect to another page and display that brand new record. Since I don't know the ID of the new record, I can't figure it out. I've tried a couple variations of max, but to no avail. Here's the code (part of it).
con.Execute "insert into Groups (GroupName, TaxID, HospitalBased, Hospital1, Hospital2, Hospital3, Hospital4, Loc1Addr1, Loc1Addr2, Loc1City, Loc1St, Loc1Zip, Loc1CountyCode, Loc1Region, Loc1Phone, Loc1Fax, Loc1Contact, Loc1Email, Loc2Addr1, Loc2Addr2, Loc2City, Loc2St, Loc2Zip, Loc2CountyCode, Loc2Region, Loc2Phone, Loc2Fax, Loc2Contact, Loc2Email, createdby, editedby,maindbid,TypeGroup) values " &_
"('" & txtGroupName & "','" & txtTaxID & "','" & txtHospitalBased & "'," & txtHospital1 & "," & txtHospital2 & "," & txtHospital3 & "," & txtHospital4 & ",'" & txtLoc1Addr1 & "','" & txtLoc1Addr2 & "','" & txtLoc1City & "','" & txtLoc1St & "','" & txtLoc1Zip & "','" & txtLoc1CountyCode & "','" & txtLoc1Region & "','" & txtLoc1Phone & "','" & txtLoc1Fax & "','" & txtLoc1Contact & "','" & txtLoc1Email & "','" & txtLoc2Addr1 & "','" & txtLoc2Addr2 & "','" & txtLoc2City & "','" & txtLoc2St & "','" & txtLoc2Zip & "','" & txtLoc2CountyCode & "','" & txtLoc2Region & "','" & txtLoc2Phone & "','" & txtLoc2Fax & "','" & txtLoc2Contact & "','" & txtLoc2Email & "','" & user & "','" & user & "','" & txtmaindbid & "','" & TypeGroup & "')"
con.Close
set con=nothing
Response.Redirect("/cfdev/app/Groupdetail.asp?GroupID=Max(PID)")
end if
set rs1=server.CreateObject("ADODB.Recordset")
rs1.ActiveConnection=con
rs1.Open "Select HospID, HospName from hospitals where deleted=0 order by HospName"
do until rs1.EOF or i=500
i=i+1
hospitalId(i)=rs1(0)
hospitalName(i)=rs1(1)
rs1.MoveNext
loop
rs1.Close
set rs1=nothing
con.Close
set con=nothing
Any help is appreciated as always!
Users can create a new record in my dbase. Everything works fine wout problems. What I"m haveing trouble with is after the new record is created, I was to redirect to another page and display that brand new record. Since I don't know the ID of the new record, I can't figure it out. I've tried a couple variations of max, but to no avail. Here's the code (part of it).
con.Execute "insert into Groups (GroupName, TaxID, HospitalBased, Hospital1, Hospital2, Hospital3, Hospital4, Loc1Addr1, Loc1Addr2, Loc1City, Loc1St, Loc1Zip, Loc1CountyCode, Loc1Region, Loc1Phone, Loc1Fax, Loc1Contact, Loc1Email, Loc2Addr1, Loc2Addr2, Loc2City, Loc2St, Loc2Zip, Loc2CountyCode, Loc2Region, Loc2Phone, Loc2Fax, Loc2Contact, Loc2Email, createdby, editedby,maindbid,TypeGroup) values " &_
"('" & txtGroupName & "','" & txtTaxID & "','" & txtHospitalBased & "'," & txtHospital1 & "," & txtHospital2 & "," & txtHospital3 & "," & txtHospital4 & ",'" & txtLoc1Addr1 & "','" & txtLoc1Addr2 & "','" & txtLoc1City & "','" & txtLoc1St & "','" & txtLoc1Zip & "','" & txtLoc1CountyCode & "','" & txtLoc1Region & "','" & txtLoc1Phone & "','" & txtLoc1Fax & "','" & txtLoc1Contact & "','" & txtLoc1Email & "','" & txtLoc2Addr1 & "','" & txtLoc2Addr2 & "','" & txtLoc2City & "','" & txtLoc2St & "','" & txtLoc2Zip & "','" & txtLoc2CountyCode & "','" & txtLoc2Region & "','" & txtLoc2Phone & "','" & txtLoc2Fax & "','" & txtLoc2Contact & "','" & txtLoc2Email & "','" & user & "','" & user & "','" & txtmaindbid & "','" & TypeGroup & "')"
con.Close
set con=nothing
Response.Redirect("/cfdev/app/Groupdetail.asp?GroupID=Max(PID)")
end if
set rs1=server.CreateObject("ADODB.Recordset")
rs1.ActiveConnection=con
rs1.Open "Select HospID, HospName from hospitals where deleted=0 order by HospName"
do until rs1.EOF or i=500
i=i+1
hospitalId(i)=rs1(0)
hospitalName(i)=rs1(1)
rs1.MoveNext
loop
rs1.Close
set rs1=nothing
con.Close
set con=nothing
Any help is appreciated as always!