CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 1999
    Location
    Sweden
    Posts
    33

    can't use same connection to both a RS and Command when in transaction

    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


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: can't use same connection to both a RS and Command when in transaction

    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)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured