Executing SQL Querys in Code

Posted on 2014-02-11
Last Modified: 2014-02-13
Is there  a simpler approach to updating a SQL Table than all this?  All this cross linkage of Transactions, Querys and Databases?  Do all Querys need transactions?

  IBDatabase1.DatabaseName := 'c:\backupdbs\JPBD.IB';

  IBDatabase1.DefaultTransaction := IBTransaction1;
  IBTransaction1.DefaultDatabase := IBDatabase1;

  IBQuery1.Transaction := IBTransaction1;

  IBQuery1.Database := IBDatabase1;
  IBQuery1.SQL.Add('Insert into Employee(PersonID, LastName) Values(1, ''Price'')');
Question by:CiaoBaby
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 70

Expert Comment

ID: 39851890
That again depends on the database system you are using. But most times you do not need transactions, which results in autocommiting all changes without chance to rollback changes.

Transactions are used to bundle several commands into a single "atomic" operation. They don't make much sense with a single command.
LVL 34

Accepted Solution

ste5an earned 500 total points
ID: 39852631
The IB prefix sounds like FireBird. And yes, here you need explicit transactions. Well, abstraction is your friend. Encapsulate theses actions in an appropriate class model.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question