Click to See Complete Forum and Search --> : can't use same connection to both a RS and Command when in transaction


jen
August 2nd, 2000, 04:48 AM
Hi
I want to use a connection in a function to do som stuff:
all written in half pseudocode, half vbcode so I have excluded som properties of the objects

con.Open mypath
rs.Open mystring, con

con.BeginTrans
cmd.ActiveConnection = Con

While Not rs.EOF
cmd.Parameters.Append cmd.CreateParameter(, adInteger, adParamInput, , rs!ID)
cmd.Execute
cmd.Parameters.Delete (1)
rs.MoveNext
Wend

con.CommitTrans




But I recieve an errormessage when I do something like this. "Cannot create new connection because in manual transaction mode". If I use 2 separate connectionobjects there is no problem but that is what I wanted to avoid...
Is there some way to get around this?
jen

Lothar Haensler
August 2nd, 2000, 07:26 AM
try this alternate approach:


dim a as variant
rs.open mystring, con
a = rs.GetRows() ' read all results into a variant
dim i as integer
con.begintrans
set cmd.activeconn = con
cmd.parameters.append cmd.createparameter(...)
for i = 0 to ubound(a,2)
cmd.parameters(1).value = a(3,i)
next i
con.commitTrans



all PCode (kind of)