Everything posted by Mikheil
Mikheil posted a topic in DatabasesI used to do a lot of programming in Delphi 6. I was a Novell Developer. I'm now retired for quite some time. I was asked to do a bit of work for a friend. His company programmer is off sick and on a pension, I can always use a bit of extra cash! I've done most of the work. I'm using Rad Studio XE7 and MyDac for his database work. I created a database and tables at runtime. I've done all the data entry work, but now he wants to run a simple query and show the results in a dbGrid (or something similar. To be honest, I'm clueless on this one. At 80, the gray cells don't work as well as they did years ago plus I don't recall ever having to do this. the query is very simple there is only one table involved. the object is to first ask for the query, there are 5 possible fields only one of the queries involves an OR statement. - Select * from <tablename> where field1 LIKE "%string%" OR field2 LIKE "%string%" The others would involve only one field. It sounds incredibly simple, but it's got me scratching my head. Age is a bad thing! I thought of a dbListbox Display the possible items for the user to select. Create the query, feed this into a MyQuery, execute it and somehow feed the result into a dbGrid. Is there a way to do this. Any help would be most welcome so that I can tie this one up?
Mikheil replied to Mikheil's topic in DatabasesPlease just forget I asked a question. I think I must be on the wrong forum or maybe the wrong planet., because none of the answers bear any resemblance to my question. I'll just forgo the money and tell my friend to wait until his programmer has recovered. I honestly thought that I asked a clearly worded question. I was obviously wrong, so let's just forget I ever asked it.
Mikheil replied to Mikheil's topic in DatabasesI'm afraid that you seem to have missed my point. The query string isn't the problem. I appreciate your comments regarding LIKE, but there's a phrase "The customer is always right". I'm not writing this for me. He has reasons for the LIKE. DBGrid --> TDatasource -->TQuery Is the bit that I'm out of my depth with. I create a Form. I drop a DBGrid onto it. I have a DataModule with the TMyConnection TMyTable, TMyCommand, and TDatasource in it. Where / how to I put the TQuery? On the Form or in the DataModule? Do I need a second DataSource if so where to put it? How do I link these together at runtime? The next thing is how to allow the user to select which field(s) to query, so that I can construct the SQL? Should I create a separate mini form for that or can I hold off displaying the DBGrid AFTER the user has made the selection and I've created the SQL string? Don't get old!