May 29, 2024, 05:45:58 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


MySQL help

Started by billhsln, July 07, 2023, 06:40:36 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

billhsln

I can't seem to connect to the MySQL Workbench on my PC.  I may not have it configured right, since even in the workbench when I test the connection, it does not work.  So, any help will be appreciated and if someone could test the following program and let me know if it works, I would appreciate it.

' DB_test_MySQL.iwb

DEF pdb:POINTER
DEF mysqlserver[16]="localhost", mysqldatabase[16]="sakila":ISTRING
DEF mysqluser[16]="root", mysqlpw[16]="", mysqloption[16]="3":ISTRING

OPENCONSOLE

pDB=dbConnect("MySQL ODBC 8.0 Unicode Driver","Server="+mysqlserver _
               +";Database="+mysqldatabase+";User="+mysqluser+";Password="+mysqlpw _
               +";Option="+mysqloption+";","")
IF pdb <> NULL
PRINT "Connection established"
pTables = dbListTables(pdb)
PRINT "Tables:"
IF pTables <> NULL
FOR temp = EACH pTables as STRING
PRINT #temp
PRINT "Cardinality:",dbCardinality(pdb,#temp)
PRINT "\tColumns:"
pointer pColumns = dbListColumns(pdb,#temp)
IF pColumns
pointer temp2
FOR temp2 = EACH pColumns as STRING
PRINT "\t\t",#temp2
NEXT
ListRemoveAll(pColumns,TRUE)
ENDIF
NEXT
ListRemoveAll(pTables,TRUE)
ELSE
PRINT "Unable to list tables"
ENDIF
dbDisconnect(pdb)
ELSE
PRINT "Unable to connect to database"
ENDIF

LABEL done
WAITCON
END

Thanks,
Bill
When all else fails, get a bigger hammer.

billhsln

I got it to work, it seems that I didn't have the MySQL setup correctly and it wasn't running.

Bill
When all else fails, get a bigger hammer.