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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Whats wrong with this code?

Status
Not open for further replies.

schase

Technical User
Sep 7, 2001
1,756
US
I've tried leaving the connection open, and closing it later, I've tried grouping, I've a couple different methods for the insert multiple records part.

The first part inserts great, the second it either looks like it's inserting or I get open errors.

<%
Dim MyConn, RS, fldSurveyID, fldSalesPerson, fldVehicle, fldCableYes, fldRadio, fldStation, fldComment1, fldComment2

fldSurveyID = Session(&quot;svSurveyID&quot;)
fldSalesPerson = Request.Form(&quot;fldSalesPerson&quot;)
fldVehicle = Request.Form(&quot;fldVehicle&quot;)
fldCableYes = Request.Form(&quot;fldCableYes&quot;)
fldRadio = Request.Form(&quot;fldRadio&quot;)
fldStation = Request.Form(&quot;fldStation&quot;)
fldComment1 = Request.Form(&quot;fldComment1&quot;)
fldComment2 = Request.Form(&quot;fldComment2&quot;)


Set MyConn=Server.CreateObject(&quot;ADODB.Connection&quot;)
Set RS = Server.CreateObject(&quot;ADODB.RecordSet&quot;)

MyConn.Open &quot;dbAdvertising&quot;

RS.Open &quot;Select * From tblEntries&quot;,MyConn,adOpenDynamic,adLockPessimistic,adCMDText


RS.AddNew
RS(&quot;fldSurveyID&quot;)=fldSurveyID
RS(&quot;fldSalesPerson&quot;)=fldSalesPerson
RS(&quot;fldVehicle&quot;)=fldVehicle
RS(&quot;fldCableYes&quot;)=fldCableYes
RS(&quot;fldRadio&quot;)=fldRadio
RS(&quot;fldStation&quot;)=fldStation
RS(&quot;fldComment1&quot;)=fldComment1
RS(&quot;fldComment2&quot;)=fldComment2
RS.Update
RS.Close
MyConn.Close
%>
<%

Dim RS2, i, strQuery, fldSurveySOB

Set RS2 = Server.CreateObject(&quot;ADODB.Connection&quot;)
MyConn.Open &quot;dbAdvertising&quot;
RS2.Open &quot;Select * From tblSurveySOB&quot;,MyConn,adOpenDynamic,adLockPessimistic,adCMDText
RS2.BeginTrans

for i=1 to 8
fldSurveyID = Request.Form(&quot;fldSurveyID&quot;&i)
fldSurveySOB = Request.Form(&quot;fldSurveySOB&quot;&i)

strQuery = &quot;INSERT INTO tblSurveySOB ([fldSurveyID],[fldSurveySOB]) VALUES (&quot; _
& &quot;'&quot; & fldSurveyID & &quot;', &quot; _
& &quot;'&quot; & fldSurveySOB & &quot;)&quot;
'Response.Write strQuery & &quot;<br>&quot;
rs2.Execute strQuery

NEXT

IF rs2.Errors.Count = 0 THEN
rs2.CommitTrans
ELSE
rs2.RollbackTrans
insertcount = 0
END IF

%>
<%
RS2.Close
MyConn.Close
Set rs = nothing
Set rs2 = nothing
Set MyConn = Nothing
%> &quot;Insert witty remark here&quot;

Stuart
 
nm got it &quot;Insert witty remark here&quot;

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top