Recent

Author Topic: How do i import a data from a table as a variable in lazarus?  (Read 4894 times)

workinghard

  • Jr. Member
  • **
  • Posts: 74
Hi everyone, I'm using lazarus 0.9.30 and FPC 2.4.2. And in this program, i must import the data from a table and use it as a variable, so that i can run the calculations in the program itself, (when i do the calculation on mysql, it returns an error very often) then upload the data to the database
so, in order to do that, what should i do?

Lacak2

  • Guest
Re: How do i import a data from a table as a variable in lazarus?
« Reply #1 on: March 27, 2012, 08:24:49 am »
BTW what error returns MySQL ? Doing calculation on server side seems to me as better that read data to client do calculations and write data back  :)

workinghard

  • Jr. Member
  • **
  • Posts: 74
Re: How do i import a data from a table as a variable in lazarus?
« Reply #2 on: March 27, 2012, 09:49:37 am »
I was getting an error #1242
It's fixed now though...
thanks Lacak2 for helping

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How do i import a data from a table as a variable in lazarus?
« Reply #3 on: March 28, 2012, 05:25:05 am »
Here you can see the description of the error. Probably your query was wrong.

workinghard

  • Jr. Member
  • **
  • Posts: 74
Re: How do i import a data from a table as a variable in lazarus?
« Reply #4 on: March 28, 2012, 11:49:59 am »
But still, is it possible to do this?
Cause i really need to get this program up and running as soon as possible, since i always get a Parameter error when querying

I hoPed that by doing it this way, even though the code will be more comPlex, it will be able to be done quicker

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: How do i import a data from a table as a variable in lazarus?
« Reply #5 on: March 28, 2012, 01:31:32 pm »
Going to be a bit blunt here, but some work on your part now in understanding how things work will pay off. I know it's hard in the beginning.
Working around your programming errors by programming more inefficient code is going to work... until you hit the next error...
Working around other people's errors on the other hand.. ;)

With this behind us:
Quote
must import the data from a table and use it as a variable, so that i can run the calculations in the program itself
What have you tried yourself? What approach do you think would work? What documentation have you read and what did not make sense to you/work?

From a basic perspective, I'd extract the data from the databse, perform the calculation and store the result (= what you said in your question).
If you need to loop through a table/view when calculating data, you should do that.

What have you tried yourself? What error messages do you get?

It's very difficult to answer these kinds of questions without giving ready made snippets of code that possibly might work for you (or not at all) and probably won't help in your understanding of what is going on...
In addition, there's tons of wiki pages, Delphi tutorials, even a Lazarus book (which won't tell you this particular issue though), a Lazarus online free book by motaz (search the forum).


Regards,
BigChimp
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How do i import a data from a table as a variable in lazarus?
« Reply #6 on: March 28, 2012, 02:43:48 pm »
Quote
But still, is it possible to do this?
Why not? It's very common in database centric apps, and there are a lot of them written in Lazarus/FPC.

 

TinyPortal © 2005-2018