Link to home
Start Free TrialLog in
Avatar of networkn
networkn

asked on

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.
Avatar of jimyX
jimyX

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?
Avatar of networkn

ASKER

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.
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.
>    "The RollBack Transaction request has no corresponding Begin Transaction"
This error is related to your SQL Statement. Which database you are using?
mssql is the dB I am using
There is a "No Corresponding BEGIN TRANSACTION" bug. Is it applicable to your case?
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.
>   "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"
it won't let me attach the zip containing the project, I have put it here:

http://smtp.ssit.co.nz/files/taskview.zip
ASKER CERTIFIED SOLUTION
Avatar of jimyX
jimyX

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.