zxtnt09

Read Data From MYSQL Table

4 posts in this topic

hi guys, 

for first sorry for my lot questions,

how can i read all "id , name ,etc" and return that to msgbox.

for example : 

1 ) i have a mysql database and have this table and columns : 

table : userinfo

columns : ID , username , password , email ,etc.

2 ) now i want to return something like that in msgbox : 

ID : 1 , Username : 1

ID : 2 , Username : 2

ID : 3 , Username : 3

...

-* i have mysql database , and i was connect my program to database and all of thing is true , but i don't know how can i fix this issue ^_^

thanks all :ILA2:

 

Share this post


Link to post
Share on other sites



What you get back with the code below is a 2D-Array.
Using a loop you can pack all the contents the select returns into a Message Box,

 

#include <Array.au3>

Global $Driver = ""
Global $Server = ""
Global $DB = ""
GLobal $User = ""
Global $Pwd = ""
Global $Port = ""
Global $Select = "select * from table"


Global $RecordSet, $Data
Global $Connection = ObjCreate("ADODB.Connection")
$Connection.open ("DRIVER=" & $Driver & ";SERVER=" & $Server & ";DATABASE=" & $DB & ";UID=" & $User & ";PWD=" & $Pwd & ";PORT=" & $Port)
If @error Then
    MsgBox(16, "Fail", "Couldn't connect to database")
    Exit
EndIf

$RecordSet = $Connection.Execute($Select)
If @error Then
    MsgBox(16, "Fail", "Failed to execute query.")
    Exit
EndIf

$Data = $RecordSet.GetRows
If @error Then
    MsgBox(16, "Fail", "Failed to get rows or empty set.")
    Exit
EndIf

_ArrayDisplay($Data)

 

Share this post


Link to post
Share on other sites

columns : ID , username , password , email ,etc. :mad: :shifty:

Share this post


Link to post
Share on other sites

What you get back with the code below is a 2D-Array.
Using a loop you can pack all the contents the select returns into a Message Box,

 

#include <Array.au3>

Global $Driver = ""
Global $Server = ""
Global $DB = ""
GLobal $User = ""
Global $Pwd = ""
Global $Port = ""
Global $Select = "select * from table"


Global $RecordSet, $Data
Global $Connection = ObjCreate("ADODB.Connection")
$Connection.open ("DRIVER=" & $Driver & ";SERVER=" & $Server & ";DATABASE=" & $DB & ";UID=" & $User & ";PWD=" & $Pwd & ";PORT=" & $Port)
If @error Then
    MsgBox(16, "Fail", "Couldn't connect to database")
    Exit
EndIf

$RecordSet = $Connection.Execute($Select)
If @error Then
    MsgBox(16, "Fail", "Failed to execute query.")
    Exit
EndIf

$Data = $RecordSet.GetRows
If @error Then
    MsgBox(16, "Fail", "Failed to get rows or empty set.")
    Exit
EndIf

_ArrayDisplay($Data)

 

Thanks it's very useful

 

columns : ID , username , password , email ,etc. :mad: :shifty:

:lol: Very funny =)))) ,

And no, it is just for members.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now