Startseite › Foren › Deutsches LiveCode-Forum › Anbindung an mySQL DB scheitert › Antwort auf: Anbindung an mySQL DB scheitert
Update:
Habe mich hier nochmal durchgelesen und nun folgendes probiert, was aber ebenfalls nicht klappt:
Ich habe einen Button mit dem Namen „Connect“ und ein ausgabeFeld (field), wenn ich auf den Button klicke soll die Datenbank angesprochen werden und alles aus der Datenbank in das ausgabeFeld geschrieben/angezeigt werden. Ich habe die Datenbank heißt „livecode“, die Tabelle „Personendaten“. Ich habe die mySQL-DB über XAMPP laufen.
Im Stack steht folgender Code:
on mouseUp
— use a global variable to hold the connection ID so other scripts can use it
global gConnectionID
— set up the connection parameters – edit these to suit your database
put „MySQL“ into tDatabaseTyp
put „localhost“ into tDatabaseAddress
put „livecode“ into tDatabaseName
put „root“ into tDatabaseUser
put „“ into tDatabasePassword
— connect to the database
put revOpenDatabase(tDatabaseTyp, tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) into tResult
— check if it worked and display an error message if it didn’t
— & set the connection ID global
if tResult is a number then
put tResult into gConnectionID
answer info „Connected to the database.“ & cr & „Connection ID = “ & gConnectionID
else
put empty into gConnectionID
answer error „Unable to connect to the database:“ & cr & tResult
end if
end mouseUp
Auf dem Button (Name Connect) steht folgender Code:
global gConnectionID
on mouseUp
put „SELECT * FROM personendaten“ into sql
put revDataFromQuery(tab,return,dbid,sql) into ergebnis
put ergebnis into field „ausgabeFeld“ of card „startseite“
end mouseUp
Als Fehlermeldung bekomme ich:
button „Connect“: execution error at line n/a (External handler execution error: revdberr,invalid connection id) near „revdberr,invalid connection id“
Bitte um Hilfe, vielen Dank!