Results 1 to 2 of 2


  1. #1
    Join Date
    Dec 1969

    Default COM, ASP AND MTS

    Hello, <BR>I&#039;m trying to transfer data from ASP to COM and update two <BR>tables and use MTS within COM to complete the transaction, please let me know if I&#039;m using the correct syntax, or should I be using the GetObjectContext() from ASP, if so where would I use the objOContext.CreateInstance("UpdateSNGB.UpdateData" ) <BR><BR>Thanks, <BR><BR><BR>ASP <BR>**** <BR>Dim conn <BR>Dim nsymbol <BR>Dim ncompany <BR><BR>nsymbol = request.form("symbol") <BR>ncompany = request.form(companyname) <BR>Set conn = Server.CreateObject("UpdateSNGB.UpdateData") <BR>conn.UpdateTables(nsymbol, ncompany) <BR><BR><BR>COM OBJECT(dll) <BR>*************** <BR>Public Function UpdateTables(nsymbol, ncompany) <BR>&#039;Declare variables <BR>Dim MyConn, RS, RS2 <BR>Dim oc as ObjectContext <BR>Set oc = GetObjectContext() <BR>&#039;in this case, since we&#039;re adding to two separate tables we need to create two instances of the RecordSet Object <BR>Set MyConn = Server.CreateObject("ADODB.Connection") <BR>Set RS = Server.CreateObject("ADODB.RecordSet") <BR>Set RS2 = Server.CreateObject("ADODB.RecordSet") <BR>&#039;getdata is your DSN (data source name) you created in ODBC <BR>MyConn.Open "StrConn" <BR>&#039;open both RecordSets <BR>RS.Open "Select * From GBOrderEntry", MyConn, adOpenDynamic, adLockPessimistic, adCMDText <BR>RS2.Open "Select * From SNOrderEntry", MyConn, adOpenDynamic, adLockPessimistic, adCMDText <BR>&#039;Update the first RecordSet <BR>RS.AddNew <BR>RS("Symbol") = nsymbol <BR>RS("CompanyName") = ncompany <BR>RS.Update <BR>&#039;Update the second RecordSet <BR>RS2.AddNew <BR>RS2("Symbol") = nsymbol <BR>RS2("CompanyName") = ncompany <BR>RS2.Update <BR>&#039;Close connections <BR>RS.Close <BR>RS2.Close <BR>MyConn.Close <BR>Set RS = Nothing <BR>Set RS2 = Nothing <BR>Set MyConn = Nothing <BR>oc.SetComplete <BR>Set oc = Nothing <BR>End Function

  2. #2
    Karin van Ettinger Guest

    Default RE: a few tips and answers

    a few tips and answers to complete your code!<BR><BR>&#039; Important for the aspect "Early Binding"<BR>make an explicit dim statement like <BR> Dim MyConn as ADODB.Connection <BR><BR>&#039; to access the MTS Context Object<BR>Set oc = GetObjectContext <BR><BR>&#039; to use the same context in other MTS-objects<BR>For every MTS-object you&#039;ll create in the MTS Component create it as follows:<BR> oc.CreateInstance("your component")<BR><BR>&#039; IMPORTANT for non-MTS objects like ADO-objects<BR>For every NON MTS-Object like the ADODB-objects create it as follows:<BR> set MyConn = New ADODB.Connection<BR>or (a bit less efficient)<BR> Set MyConn = server.CreateObject("ADODB.Connection") <BR><BR>at the end <BR>if OK Then<BR> oc.SetComplete<BR>else<BR> oc.SetAbort<BR>end if<BR><BR>IMPORTANT:<BR> after oc.SetComplete all the resources are free again. So if you had some properties for that component - they have gone.<BR><BR>

Posting Permissions

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