Results 1 to 2 of 2

Thread: Transactions

  1. #1
    Join Date
    Dec 1969

    Default Transactions

    Hi,<BR>I have 2 questions<BR>a)<BR>I have an asp page in which I have a set of updates of tables and insertions .Now I need to club all of them into a single transaction.In case one of them fails or an error occurs it must roll back.Now in the beginning of the page I have inserted code like this<BR><BR>connstr="DSN=chainchain;UID=sa;PWD=sen orita"<BR>set conn=Server.CreateObject("ADODB.Connection")<BR>co nn.ConnectionString=connstr<BR>conn.Open<BR>conn.B eginTrans<BR><BR><BR>and in the end<BR><BR>if conn.Errors.Count=0 then<BR>conn.CommitTrans<BR>else <BR>conn.RollbackTrans<BR>conn.close<BR><BR>Now in this page it would not roll back when there is a syntax or some other error in between.What should I do so that it rolls back when there is a syntax error .<BR>b)How can I know whether a table exists in the database?The table could also exist as a structure without any rows.<BR><BR>Leejo<BR>

  2. #2
    Join Date
    Dec 1969

    Default ADODB Transactions

    They are rolled back if not specifically committed.<BR><BR>So, if you have a syntax error after calling BeginTrans and then doing an INSERT. The insert will be rolled back.<BR><BR>To find out if a table exists in a database. If SQL Server, look at the system tables. sysobjects might be it - I would have to look it up in the Books Online. In MS Access, just do a SELECT * FROM TABLE. If you get an error, you know the table didn&#039;t exist. If you don&#039;t get an error, the table exists. If you get an EOF, you know the table was empty. If not, it contains data.<BR><BR>-Doug

Posting Permissions

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