Does any one have an example of using a MySQL database from an external server?
Hoping it is something simple like:
pdb = dbConnect("MySQL Server","","Driver={MySQL};Server=40.40.40.40;Uid=<userid>;Pwd=<password>")
My Boss wants a program I am writing to access a MySQL database rather than MS Access, which I am ok with, just need to know how to access MySQL from IWB.
Thanks,
Bill
Bill,
Never tried this myself, but here is a code snippet I once saved on my old harddisk.
Good Luck!
Egil.
' connect server database.eba
' connect to database on server
' ibasic pro code, needs the database pak installed
DEF pdb:POINTER
DEF hstmt_select:INT
def sel$:STRING
openconsole
pdb = dbConnect("MySQL ODBC 3.51 Driver","","database=yourdatabase;server=servername;uid=yourid;pwd=yourpassword;")
'pdb= dbConnect("MySQL ODBC 3.51 Driver","","SERVER=69.57.180.65;PORT=3306; DATABASE=yourdatabase;USER=youruser;PASSWORD=yourpassword;OPTION=3")
if pdb=0
Print "Database Failed to Open!!<BR>"
ELSE
print "Database opened successfully!<BR>"
GetdbData()
print
print key," - ",var1," ",var2," Level ",var3
print
print "Closing conection!!<BR>"
dbFreeSQL(hstmt_select)
dbDisconnect(pdb)
ENDIF
do:until inkey$<>""
closeconsole
setexitcode 10
end
SUB GetdbData()
def v:INT
sel$="SELECT * FROM phpsp_users WHERE name="+chr$(34)+var1+chr$(34)
hstmt_select=0
hstmt_select = dbExecSQL(pdb,sel$)
IF hstmt_select
While dbGet(hstmt_select)
dbGetData(hstmt_select,1,var1)
dbGetData(hstmt_select,3,var2)
dbGetData(hstmt_select,5,var3)
ENDWHILE
ENDIF
RETURN
ENDSUB
Thank you, that looks like what I would expect would be needed to connect via the web.
Thanks,
Bill
Took a while testing various options, but the following finally worked for MySQL run as LocalHost:
pDB=dbConnect("MySQL ODBC 8.0 ANSI Driver","Server=localhost;Database=MyDB;User=root;Password=password;Option=3;","")
Bill