Using a BeginTrans w/ a Command Object

Results 1 to 2 of 2

Thread: Using a BeginTrans w/ a Command Object

  1. #1
    Cheryl Guest

    Default Using a BeginTrans w/ a Command Object

    Is it possible to use a BeginTrans/CommitTrans with a command object? If so, how?<BR><BR>I&#039d like to use the BeginTrans/CommitTrans when inserting data into my Access database, but I also need to insert strings that may contain single and double quotes and the best way I know of to handle this is using a Command Object.<BR><BR>Set oCMD = Server.CreateObject("ADODB.Command") <BR><BR>oCMD.CommandText = "INSERT INTO tblTable(Field1, strField2, strField3) " & _<BR> "VALUES (?, ?, ?);"<BR><BR> oCMD.ActiveConnection=Application("database_Connec tionString")<BR> oCmd.Parameters.Append oCmd.CreateParameter("Field1", adInteger, adParaminput, , data1)<BR> oCmd.Parameters.Append oCmd.CreateParameter("strField2", adVarChar, adParaminput, 20, stringdata1)<BR> oCmd.Parameters.Append oCmd.CreateParameter("strField3", adVarChar, adParaminput, 20, stringdata2)<BR><BR> oCmd.Execute<BR><BR> set oCmd = nothing<BR><BR><BR>Using the above example, how would I incorporate a BeginTrans/CommitTrans?<BR><BR>Thanks.<BR><BR>Cheryl

  2. #2
    Join Date
    Dec 1969

    Default RE: Using a BeginTrans w/ a Command Object

    The way to do this is to use a connection object along with the command object:<BR><BR>set conn = Application("database_ConnectionString")<BR>conn.o pen<BR>ocmd.ActiveConnection = conn<BR>conn.BeginTrans<BR><BR>{ocmd Code}<BR><BR>conn.CommitTrans<BR>conn.close

Posting Permissions

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