Hi,
Please advise how to read and store the data which is available in MySQL database.
Hi,
Please advise how to read and store the data which is available in MySQL database.
There are examples in the LR at: http://documentation.xojo.com/index.php/Mysql
Basically, you need to connect to your database and then query it.
Create a new property of App: db as MySQLCommunityServer first and then connect to it.
db = New MySQLCommunityServer
db.Host = "192.168.1.172"
db.Port = 3306
db.DatabaseName = "BaseballLeague"
db.UserName = "broberts"
db.Password = "streborb"
If db.Connect Then
// Use the database
Else
// Connection error
MsgBox(db.ErrorMessage)
End If?
(Change the credentials to yours obviously.)
Thanks,
I have already connect the database as mention above… Database was working fine…
Now i want to read the data from the database and stored one variable.
I have using the below code , but its not working
Dim sql As String
sql = “SELECT * FROM reply_message”
Dim rs As RecordSet
rs = db.SQLSelect(sql)
If db.Error Then
MsgBox("DB Error: ")
Return
End If
If rs <> Nil Then
While Not rs.EOF
ReplyMessage = rs.Field("message").StringValue
Recipeint_Number = rs.Field("Senderno").StringValue
rs.MoveNext
Wend
rs.Close
End If
Is your query returning multiple rows?
If so, you’ll only see the last one as you replace ReplyMessage and Recipeint_Number on every row.
Or are you getting an error from your database?
Replace your error checking with:
If db.Error Then
MsgBox("DB Error: " + Str(db.ErrorCode) + " - " + db.ErrorMessage)
Return
End If
It might be worth reviewing the code in the MySQL example project:
Examples/Database/MySQL/MySQLExample