Mysql Database problems

Just starting out? Need help? Post your questions and find answers here.
hellzone
New User
New User
Posts: 2
Joined: Sat Mar 06, 2004 7:17 pm

Mysql Database problems

Post by hellzone »

Right i've been able to connect to the database, not a problem.
I've been able to run Sql queries on the database again not a problem.
But when i try to retrieve data from the database using GetDatabaseString() in the following sytax's
GetDatabaseString(usrname)
GetDatabaseString("usrname")
GetDatabaseString(1)

All of the above return absolutely nothing at all even though there is only one row available for negeoation and the "usrname" field is infact filled with data and is of varchar format.

Any help?
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Rows in a database start at 0, so if your query only returns data from a single row, you must use GetDatabaseString(0).

If you had a table called "Clients" and this table contained 2 columns called "First" and "Last", and your query looked like this...

Code: Select all

If DatabaseQuery("Select Clients.First,Clients.Last from Clients Order by Clients.Last ASC;")
  While NextDatabaseRow()
    debug GetDatabaseString(0)
    debug GetDatabaseString(1)
  Wend
EndIf
This will retrieve the data "First" and "Last" (in that order) from the table "Clients" sorted by "Last" in ascending order.
So column position 0 will contain the data in column "First" and column position 1 will contain the data in column "Last".

The While/Wend loop continues until all data has been retrieved.

Make sense? ;)
Image Image
Post Reply