Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread Error trying to use MySQL ODBC
Sun, May 7 2017 3:43 PMPermanent Link

Big Al

Have setup 32 bit ODBC for MySQL 3.51 driver and it tests fine.

Add the database to my ewb project. It sees the tables, etc.

Added a dataset for ZipCode which is the name of the table.

Drop a dataset onto my form. Dropped a grid onto my form.

Set Dataset in the grid to my ZIpCode dataset.

On tForm.show I tried
   Database.Load(ZipCode);
which I saw in one of the videos, but in one of the example apps, I saw
  Database.LoadRows(ZipCode);
which would allow the compile

but when I run it I get

Database load response error (Database "default" not found) Line 1
I have a default database on the ODBC DSN, and also the Database properties in Database Manager

Any ideas?
Sun, May 7 2017 3:48 PMPermanent Link

Big Al

Big Al wrote:

Have setup 32 bit ODBC for MySQL 3.51 driver and it tests fine.

Add the database to my ewb project. It sees the tables, etc.

Added a dataset for ZipCode which is the name of the table.

Drop a dataset onto my form. Dropped a grid onto my form.

Set Dataset in the grid to my ZIpCode dataset.

On tForm.show I tried
   Database.Load(ZipCode);
which I saw in one of the videos, but in one of the example apps, I saw
  Database.LoadRows(ZipCode);
which would allow the compile

but when I run it I get

Database load response error (Database "default" not found) Line 1
I have a default database on the ODBC DSN, and also the Database properties in Database Manager

Any ideas?


I unchecked compress output so I got a real line number 19,852.

This is the code:

webdata_tdataset.$p.doloaderror = function(errormsg)
{
  var $t = this;
  if ($t.tdataset_fonloaderror)
     $t.tdataset_fonloaderror($t, errormsg);
  else
     throw new Error(errormsg);
};

Still doesn't tell me anything much..

Alan
Sun, May 7 2017 6:03 PMPermanent Link

Raul

Globestar Systems

Team Elevate Team Elevate

On 5/7/2017 3:48 PM, Big Al wrote:
> Big Al wrote:
> Have setup 32 bit ODBC for MySQL 3.51 driver and it tests fine.
> Add the database to my ewb project. It sees the tables, etc.
> Added a dataset for ZipCode which is the name of the table.
> Drop a dataset onto my form. Dropped a grid onto my form.
> Set Dataset in the grid to my ZIpCode dataset.
> On tForm.show I tried

You need to do one more thing which is to specify the database name -
whatever you names it in the database manager.

I'd suggest do it in the Forms OnCreate (instead of OnShow) but
basically something like this


procedure TForm1.Form1Create(Sender: TObject);
begin
   Database.DatabaseName:='<insert your database name>';
   Database.Loadrows(ZipCode);
end;

This is one time operation and nice thing with this design is that for
example you can switch between dev/test/prod databases by changing
DatabaseName entry only - everything else would remain same.

Raul
Sun, May 7 2017 7:10 PMPermanent Link

Big Al

>Raul wrote:


>I'd suggest do it in the Forms OnCreate (instead of OnShow) but
>basically something like this

Raul,
Thanks,
I'm now getting an error that a column doesn't exist, but I'm getting closer.
That's probably something I'm doing wrong, so I will keep working with it.

Thanks so much for your help.
Alan
Sun, May 7 2017 7:31 PMPermanent Link

Raul

Globestar Systems

Team Elevate Team Elevate

On 5/7/2017 7:10 PM, Big Al wrote:
> I'm now getting an error that a column doesn't exist, but I'm getting closer.
> That's probably something I'm doing wrong, so I will keep working with it.
> Thanks so much for your help.
> Alan

Alan,

Not sure how much it helps but i recall writing some quick steps in
getting started using datasets - i think it's this one and while it's
older it should still be valid :

http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_general&page=1&msg=11345#11345

and the steps themselves (in your case use your own database):

General steps that work for me using sample data on 2.05 B4:

1. File -> new project and base it on TForm

2. Go to database manager and make see ExampleData database and open and
preview data for "Products" dataset (it should have 9V-BATTERY-12PK as
1st prodct item etc.) ?

3. drag the Products dataset to your form

4. drop a grid on the form

5. set grid dataset to Products (this should auto populate grid columns)

6. double click on empty form area and you should get to FormCreate
event and add databasename and then loadrows. it should look as follows:

procedure TForm1.Form1Create(Sender: TObject);
begin
   Database.DatabaseName:='ExampleData';
   Database.Loadrows(Products);
end;

7. compile and run - you should see data in grid now

If you do not then either your web server is not properly running or
dataset resource name is off.

You can quickly test using URL in browser :

http://localhost:<web server
port>/databases?method=rows&database=ExampleData&dataset=Products

If you do not see data then something in your config is not valid.


Raul
Mon, May 8 2017 10:10 AMPermanent Link

Big Al

>Raul wrote:


>Alan,

>Not sure how much it helps but i recall writing some quick steps in
>getting started using datasets - i think it's this one and while it's
>older it should still be valid :


>Raul

Thanks, I did get it working. Lots to learn, but I'm extremely pleased so far.

Big Al
Mon, May 8 2017 11:35 AMPermanent Link

Big Al

What would you do as far as database name, if you wanted to open two databases?
Is there some sort of option to do that?

Alan
Mon, May 8 2017 12:09 PMPermanent Link

Raul

Globestar Systems

Team Elevate Team Elevate

On 5/8/2017 11:35 AM, Big Al wrote:
> What would you do as far as database name, if you wanted to open two databases?
> Is there some sort of option to do that?

For the 2nd database you need to minimally create your own database
instance  (File->New->Database) and use that instead of the default
database that EWB has.

I'd even go as far as not use the default database at all and create
your own database instances for all databases you need - i believe this
keeps your code easier to understand since you're not mixing built-in
and own objects.

Raul
Tue, May 9 2017 1:54 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Alan,

<< What would you do as far as database name, if you wanted to open two databases? >>

In addition to what Raul has indicated, you can drag and drop a database from the Database Manager into the Units section of the Project Manager to create a database.  The datasets that are defined in the Database Manager are then automatically created for you in the database instance that is created in your application's project.

Tim Young
Elevate Software
www.elevatesoft.com
Image