No subject


Thu Oct 26 19:20:09 CEST 2017


> mysql> show databases;
> +--------------------+
> | Database =A0 =A0 =A0 =A0 =A0 |
> +--------------------+
> | information_schema |
> | mysql =A0 =A0 =A0 =A0 =A0 =A0 =A0|
> | test =A0 =A0 =A0 =A0 =A0 =A0 =A0 |
> | wikidb =A0 =A0 =A0 =A0 =A0 =A0 |
> +--------------------+
> 4 rows in set (0.00 sec)
>=20
> mysql>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> but I get error when run from gambas
>=20
> This is the code I use from inside gambas
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> PRIVATE $hConn AS Connection
>=20
> PUBLIC SUB btnConnect_Click()
>=20
> =A0 =A0DIM sName AS String
>=20
> =A0 =A0TRY $hConn.Close
> =A0 =A0'$hConn =3D NEW Connection
> =A0 =A0WITH $hConn
> =A0 =A0 =A0.Type =3D "mysql"
> =A0 =A0 =A0.Host =3D "localhost"
> =A0 =A0 =A0.Login =3D "zano"
> =A0 =A0 =A0.Password =3D "mypassword"
> =A0 =A0 =A0.Port =3D "3306"
> =A0 =A0 =A0.Name =3D ""
> =A0 =A0END WITH
>=20
> =A0 =A0$hConn.Name =3D "zano"
> =A0 =A0$hConn.Open
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Why do you set $hConn.Name =3D "zano" if the database name should be=20
'wikidb' where you talked about in previous posts??


You are mixing two problems.=20
1) connection to the database server

your start post:2008-02-16 22:07
> Well... the problem is that I cannot connect to mysql since I get a=20
> socket error. Gambas looks for the socket in /tmp while the working=20
> socket is /var/run/mysql, the default [1]
2008-02-18 17:34
> This is what I get when connecting with MySql.
> As you can see, there is a wikidb which I use for personal purposes.=20
2008-02-18 19:14
> What I've noticed is that it doesn't care of psw, username. It signals=20
> error with "mysql" and "localhost"
2008-02-19 11:53
> > You should use a mysql admin program, like phpadmin or mysqladmin
> > and add a user 'Zano' with or without password to the mysql server.
> > You must do it as mysql root user here.!!!
> >
> Sorry, but it doen't work.
> I've created the user zano with ALL priviledges, I can run it from termin=
al

Here the reason I told (2008-02-20 16:28) about $hConn.Name =3D "zano" !!!=
=20

2008-02-19 16:08 (answer by Benoit)
> > While writing this mail, I'm in question.
> > I run the the modified example "database" in gambas package, it shows a
> > form, a click on connect and I get the error.
> > Is it possible there is a problem in the form or something associated
> > with it?
> >

> I think it is a problem in some mysql configuration file, because, to con=
nect=20
> to the database, Gambas does nothing more than using the property of the=
=20
> Connection object.=20

> I cannot tell you more, except that nobody else have such a problem with =
the=20
> Database example, and I never got it during the development, with many=20
> different mysql versions.


2) data problems when connected.
> Hi,=20

> I donnot get it (again ;-) )
I told (2008-02-20 16:28) about wrong $hConn.Name =3D "zano" ???

> I do :
>  =A0 =A0 =A0 IF Res.Fields[CFields[i]].Type =3D db.Date THEN
>
> where Res is a valid result set and CFields[i] contains the name of the f=
ield.=20
> If I select "Res.Fields[CFields[i]].Type" in the debugger I get a 9, wich=
 is correct !

WRONG (from gambas help)
DB.Date (gb.db) Syntax CONST Date AS Integer =3D 8
DB.String (gb.db) Syntax CONST String AS Integer =3D 9

> When I run the program it stops on this line with : 'Not an Object'
> However, when i look into "Res.Fields[CFields[i]]" the object is there
> with all items filled corectly (Name, Type, ...)

How come "Res.Fields[CFields[i]]" what a single field determined by name=20
from CFields[i] contains all items filled corectly (Name, Type, ...)

> What do i do wrong ?

Telling the connection and access works and provided information was useful=
l ?
The exact gambas version in use.
Providing wrong code, the connection in previous posts, without correction =
what is done.
Are the names in CFields array of the same case as in the database, just in=
 case?
Did you create the database with the gambas-database-manager?

For the remaining not much as we also do ourselfs too :=3D)


Try following in the (sub) routine

DIM tmptype as integer
DIM tmpdata as Date

  tmptype  =3D Res.Fields[CFields[i]].Type
  tmpdata  =3D Res.Fields[CFields[i]]

  IF tmptype =3D db.Date THEN

Where does the error occur exact?

Ron








More information about the User mailing list