• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 575
  • Last Modified:

Lazarus (freePascal) DB Project Assistance

Hi

After a LONG break from development I am trying my hand for a simple project. I used to write in pascal/delphi so switched to using Lazarus. I am very very rusty almost a beginner again.

My project is a single form with a grid, and potentially 3 drop down boxes which filter the grid. I have the DBGrid displaying the SQL Query I want, but I can't get the DBComboDropDown to populate with the SQL in the SQLQuery component, despite it returning good example results. I suspect the reason the dropdown isn't populating is that I can't set the SQLquery as "active". When I try it won't change to active but I get no error. When I compile the application I either get an error when I start or when I click the button to close the project, The error I get is :

"The RollBack Transaction request has no corresponding Begin Transaction"

A quick google suggested I could stop that by setting the SQLtransaction Component "action" property to caNone, but that didn't help.

I am fairly new back to this so simple explanations would definitely help thanks.
0
networkn
Asked:
networkn
  • 6
  • 5
1 Solution
 
jimyXCommented:
Your question is not clear.
>   "but I can't get the DBComboDropDown to populate with the SQL in the SQLQuery component"
I will assume this is your question.

Did you mean DBComboBox?

You should use DBLookupComboBox and use the (ListSource, KeyField & ListField properties) to link to the DataSource that populates the items.
To do filtering on the DBGrid use the (DataSource property) of the DBGrid's SQLQuery to link to the DataSource of the DBLookupComboBox. Do not forget to add Where Clause in the DBGrid SQLQuery indicating the filtering Column "Where ColA = :ColB".
ColA in the DBGrid's SQLQuery Columns.
ColB in the DBLookupComboBox SQLQuery Columns.

You might attach your project to easy helping, if possible.
BTW: Which Laz/fpc Version you are using?
0
 
networknAuthor Commented:
Hi There!

Using the latest.

The questions are :

1) Why won't my SQLQuery object switch to "active"? I am thinking this is why my DbComboDropdown won't work.
In the SQL property for that object under results, I get the results I am expecting if I click the green play icon. Is there a debug log that shows why it won't go "active"
2) "The RollBack Transaction request has no corresponding Begin Transaction"
What is this error and why am I getting it, and how do I get rid of it?

Using 1.2.4 of Laz for Windows.
0
 
jimyXCommented:
Most probable you are missing one of the properties of the SQLQuery, that's why it refuses to connect.
Make sure you review all the properties as well as your SQL Statement and make sure it's a "SELECT" Statement.
Set the SQLTransaction property of the SQLQuery.

Any chance to get a look on your code? You can reproduce a sample project.
It makes things clear without guessing what might be wrong. We will go by probabilities if you do not show what you are doing.

>   "I get the results I am expecting if I click the green play icon. "
Are you using the default component TSQLQuery? Because I did not see any green play icon in the SQL Property of TSQLQuery that comes with Laz IDE.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
jimyXCommented:
>    "The RollBack Transaction request has no corresponding Begin Transaction"
This error is related to your SQL Statement. Which database you are using?
0
 
networknAuthor Commented:
mssql is the dB I am using
0
 
jimyXCommented:
There is a "No Corresponding BEGIN TRANSACTION" bug. Is it applicable to your case?
0
 
networknAuthor Commented:
I'll post the code momentarily after sanitizing it and hopefully you will be able to confirm, though I found that code myself and didn't know how/if it could be related.
0
 
networknAuthor Commented:
>   "I get the results I am expecting if I click the green play icon. "
Are you using the default component TSQLQuery? Because I did not see any green play icon in the SQL Property of TSQLQuery that comes with Laz IDE.

I didn't get it (green play in SqlQuery1) until all my links were made and all the components were "active"
0
 
networknAuthor Commented:
it won't let me attach the zip containing the project, I have put it here:

http://smtp.ssit.co.nz/files/taskview.zip
0
 
jimyXCommented:
Your SQL queries are simple and does not invoke that bug.
It could be due to using two TSQLTransactions. Haven't got M$SQL. However the steps to connect DBComboBox (please change to TDBLookupComboBox) and DBGrid should be simple.
Here are the steps:
1. First, when connecting TSQLQuery to TDataSource just set the DataSet property of the TDataSource to the TSQLQuery. Do not set the DataSource property of the TSQLQuery back to the TDataSource, it has another use but not this particular. The DataSource property of the TSQLQuery is used when you setup Master-Detail relation between two TSQLQueries (we are going to use it in the DBGrid to filter based on the selection on the DBLookupComboBox).
2. Use one TSQLTransaction with TMSSQLConnection and every other TSQLQuery connected to that connection.
3. If you want to show lines in the "TaskListDBGrid1" conforming with the selection of the TDBLookupComboBox just set the Datasource Property of the "GridSQLQuery1" to "UserListDataSource1" (Master-Detail setup).
4. The SQL statement of the "GridSQLQuery1" should include, as explained above, "where ColA = :ColB".
5. Make sure you open all the TSQLQueries starting with the Master "UserListSQLQuery1" and then the Detail "GridSQLQuery1".
0
 
networknAuthor Commented:
I sincerely apologise for the delay in my response. I have had 2 weeks of illness that has been pretty terrible and am back now for the first time. I won't have a chance to look at this again till the weekend at the earliest.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now