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.

 
Go Back  dBforums > Database Server Software > MySQL > MySQL to VB

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-17-04, 03:38
CC214700 CC214700 is offline
Registered User
 
Join Date: Jul 2004
Posts: 1
MySQL to VB

Im having trouble linking a MySQL database to Visual Basic. can anyone give me any pointers?

Cheers
Reply With Quote
  #2 (permalink)  
Old 07-18-04, 16:55
vududoc vududoc is offline
Registered User
 
Join Date: Jul 2001
Location: NC
Posts: 102
More information, please
1) can you connect to your data using a mySQL tool (eg mySQLFront)?
2) what version of mySQL are you using and which database (eg INNODB)?
3) do you have the appropriate rights?
4) what drivers are you using (eg myODBC)?
5) what VB are you using (vb4, vb5, vb6, .net)? Are you using ADO or DAO? What is your connection string?
Reply With Quote
  #3 (permalink)  
Old 08-31-04, 04:41
divined divined is offline
Registered User
 
Join Date: Apr 2004
Posts: 110
Greetings everybody

I`m experiecing a similar problem. The following list details the tools and versions I`m using to connect to a MYSQL database :

1) Visual Basic 6.
2) Connecting via ADO.
3) myODBC 3.51.8 win drivers. MySQL is running on a Windows XP machine.
4) I can connect via an ADO control.
5) The MySQL database is in the InnoDB format.

I have no starting clue as to how to programmatically create the connection string. Can anyone point me in the right direction?

thx, in advance

George Papadopoulos
Reply With Quote
  #4 (permalink)  
Old 08-31-04, 09:18
Daniel_Johns Daniel_Johns is offline
Registered User
 
Join Date: Jul 2004
Posts: 69
Private Sub cmdConnect_Click()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset

'connect to MySQL server using MySQL ODBC 3.51 Driver
Set conn = New ADODB.Connection
conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};"_
& "SERVER=localhost;"_
& " DATABASE=test;"_
& "UID=yourUserID;PWD=yourPassword"

conn.Open
End Sub

OR you can create a User DSN for your connection (im sure you know how to create one...)

Private Sub cmdConnect_Click()
Dim conn As New ADODB.Connection
Dim rs As New Recordset
Dim tmpstr As String

conn.Open "DSN=YourDSN"
tmpstr = "SELECT * from user"
rs.Source = mySQL
Set rs.ActiveConnection = conn
rs.CursorLocation = adUseClient
rs.Open

End Sub

Be sure you installed MyODBC drivers...

Last edited by Daniel_Johns; 08-31-04 at 09:25.
Reply With Quote
  #5 (permalink)  
Old 09-01-04, 01:50
divined divined is offline
Registered User
 
Join Date: Apr 2004
Posts: 110
Very nice! The code seems to work. I used the first code snippet and thus created no DSN.
I would like to ask if you know of any URL`s with more detailed info on connecting and accessing databases using ADO?

thx, in advance

George Papadopoulos
Reply With Quote
  #6 (permalink)  
Old 09-01-04, 09:55
Daniel_Johns Daniel_Johns is offline
Registered User
 
Join Date: Jul 2004
Posts: 69
Hi! I dont really have an exact URL that I can recommend. All I do is that go to some discussion boards such as this. In this way, you can have all the help with a lot of guys who willingy try to help others hanging around here. Just try posting here and dbforums guys will try to answer.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On