0

I m trying to use mysql db from Delphi xe7, I' m using a simple app to get a DBgrid filled from a mySQL table.

I have used one form and one datamodule.

The form has a DBGrid and the
Datamodule has the following : FireDAC Connection , Query , MySQLLinkDriver , WaitCursor and Datasource

I have linked the DBGrid to DataSource, before launching the app I can see the data in the query , but when I launch the app I got the following error :

Access violation at address ..............................

and can NOT get the data.

Any clue about this error ?

bummi
  • 27,123
  • 14
  • 62
  • 101
koul
  • 431
  • 2
  • 10
  • 20
  • However when I don't use datamodule with the same components it 's working fine. – koul Dec 17 '14 at 09:50
  • We need to see your code. That's not what a plain vanilla project should do. – TLama Dec 17 '14 at 10:04
  • There is no code source ,as I said I got it working without inserting a datamodule, is there a trick how to use delphi xe7 and datamodule ? I used to work with delphi xe3 and never had this error before . – koul Dec 17 '14 at 10:16
  • 4
    Then the only expanation is that the form is created first and it tries to access not yet created datamodule (because you've enabled the evil `Active` property on your dataset at design time). Could you check the order in which the forms/datamodules are created in your *.dpr project file ? – TLama Dec 17 '14 at 10:19
  • 1
    Or [`try this`](http://i.imgur.com/7mdyPRD.png). – TLama Dec 17 '14 at 10:41
  • Or the project does not autocreate its forms/modules (other than the mainform) and your forgot to create the data module in code. See *Project Options/Forms* and *Tools/Options/Environment Options/VCL Designer/Auto create forms & Data Modules* – Jan Doggen Dec 17 '14 at 12:16
  • You ve right TLama but stil does not working. I ve found that datamodule was in auto-create-form list put it in available-form list does not solve the issue. Question should I re-create an instance for the datamodule in the main Form ? – koul Dec 17 '14 at 12:46
  • 1
    You tumbled in one of the pitfalls of "RAD" design. Don't program at design time, add code to do these things at run time, this will give you more control over these kind of problems... – whosrdaddy Dec 17 '14 at 13:20
  • 1
    `I ve found that datamodule was in auto-create-form list put it in available-form list does not solve the issue.` TLama didn't ask to put it in the available-form list but to switch the order of Form1 and DataModule1 so DataModule1 is always created first. – Rik Dec 17 '14 at 15:05
  • 1
    Put the datamodule back in the auto-create forms list, and then move it up to be created before the main form. Other than that, you've provided no details that will help us resolve this, because "Access violation at address....." is an incomplete error message that has no value. (The addresses are important, because certain addresses can tell you *exactly* what is causing the problem. Your choosing not to include them is a poor choice.) – Ken White Dec 17 '14 at 16:12
  • 1
    Also, your question title is not useful. "Delphi" and "MySQL" are both provided in your tags, so your title has absolutely no meaningful content. Please [edit] and change it to something that actually describes the problem you're asking us to help you solve, so that it's useful to future readers who find it in a search result when they're trying to get help here. Thanks. – Ken White Dec 17 '14 at 16:19
  • Thanks guys specially TLama, your suggestion solve the issue. – koul Dec 18 '14 at 20:23
  • This question appears to be off-topic because the answer is in the comments. – NGLN Dec 19 '14 at 18:20

0 Answers0