If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
Can someone please give me the correct syntax for retrieving data from a mysql table and putting it into a textbox? I have the connection string and everything else. I just need the command to populate the textbox.
textbox.text= ?
I got that from someone else, but that could get messy because there are lots of fields in my query. I want to use a datagrid but have no idea about how to do it.
Thanks
Dim rs As ADODB.Recordset
Dim DB As New ADODB.Connection
Dim sSQL As String
sSQL = "select * from look_up"
DB.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=survey"
DB.Open
rs.Open sSQL, DB
'Set rs = New ADODB.Recordset
Set DataGrid1.DataSource = rs
1) Declare your recordset globally (outside of the Sub) since when the sub finishes the recordset goes out of scope and closes and so does the grid.
2) You must create a new rceordset (you have that line commented out.
Here is what this should look like
Private rs As ADODB.Recordset
Private Sub cmdSelect_Click()
Dim DB As New ADODB.Connection
Dim sSQL As String
sSQL = "select * from look_up"
DB.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=survey"
DB.Open
Set rs = New ADODB.Recordset
rs.Open sSQL, DB
Set DataGrid1.DataSource = rs
End Sub
__________________
In abundance of water only the fool is thirsty. Bob Marley.
Thanks Rami. I found this, rs.CursorLocation = adUseClient in another forum as I was getting desperate and didn't hear from you. I have no idea what adUseClient means, so if you could explain that I would be grateful. My program works fine now. Are you Israeli?
Thanks again.