6 Replies - 3779 Views - Last Post: 27 April 2011 - 02:02 PM Rate Topic: -----

#1 kiad_198  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 130
  • Joined: 19-November 08

How to convert MS Access Database connection into MySQL Database?

Posted 27 April 2011 - 07:41 AM

Hi Guys!

I try to update my knowledge from MS Access Database connection into MySQL Database connection. I've learned much in ms access Database and this my first time to learn MySQL Database. How can I convert my code to MySQL ODBC connection?
I've installed MySQL ODBC 3.5.1 and MySQL ODBC 5.1 driver for sure purposes. :)

Module form code in ms access : (ActiveX Data 2.8 library)

Public con As New ADODB.connection
Public rs As New ADODB.Recordset

Public Sub connection()
Path = App.Path & "\dbuser.mdb"
con.Open "provider = microsoft.jet.oledb.4.0;data source = " & Path
con.CursorLocation = adUseClient
End Sub



I would grab this opportunity to add more code using ms access database:

ADD button code :
connection
rs.Open "select * from tbluser where userid = '" & txtuserid.Text & "'", con, 3, 3
  If rs.RecordCount = 0 Then
                rs.AddNew (if you want to edit just change the rs.AddNew to rs.Update)
                    rs("userame") = txtuser.text
                    rs("Password") = txtpass.text
                    rs("type") = cbotype.text
                    rs("T_IN") = lbltimein.Caption
                    rs("D_IN") = lblsdatein
                rs.Update
  end if 
rs.Close: Set rs = Nothing
con.Close: Set con = Nothing



I like this code because its easy to understand for me. It would help for others looking for connection to ms access database.

I've try to setup Adodc component and it connect to MySQL DSN perfectly. I'm still in that stage of learning right now. I've try to convert that code but it didn't work.



Need help here please...

Thanks...

Kiad

Is This A Good Question/Topic? 0
  • +

Replies To: How to convert MS Access Database connection into MySQL Database?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9572
  • View blog
  • Posts: 36,244
  • Joined: 12-June 08

Re: How to convert MS Access Database connection into MySQL Database?

Posted 27 April 2011 - 07:47 AM

Quote

How can I convert my code to MySQL ODBC connection?

Are you asking to have folk convert your code? Are you running into a specific problem? Where? How is it not working? An exception? What and where?
Was This Post Helpful? 0
  • +
  • -

#3 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: How to convert MS Access Database connection into MySQL Database?

Posted 27 April 2011 - 08:04 AM

I think he's just having trouble finding the right connectionstring value. kiad, everyone's favorite resource for finding the right connectionstring is www.connectionstrings.com . Suppose you browse around in there and see if you find what you are looking for.

This post has been edited by BobRodes: 27 April 2011 - 08:05 AM

Was This Post Helpful? 0
  • +
  • -

#4 kiad_198  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 130
  • Joined: 19-November 08

Re: How to convert MS Access Database connection into MySQL Database?

Posted 27 April 2011 - 08:17 AM

Hi Guys!

Thanks for the reply...

I guest I found the answer to my question. Just alittle bit testing....


kiad :)
Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: How to convert MS Access Database connection into MySQL Database?

Posted 27 April 2011 - 08:19 AM

Very good. Suppose you tell us what the answer is, so that you can help the next person who has the problem?
Was This Post Helpful? 0
  • +
  • -

#6 kiad_198  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 130
  • Joined: 19-November 08

Re: How to convert MS Access Database connection into MySQL Database?

Posted 27 April 2011 - 08:35 AM

Here's the modified connection: (ActiveX Data 2.8 library)
Public con As New ADODB.connection
Public rs As New ADODB.Recordset

Public Sub connection()
con.Open "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=test; User=root;Password=root123;Option=3;"
con.CursorLocation = adUseClient
End Sub



It works now...
same as add button code:

thanks....


kiad
Was This Post Helpful? 0
  • +
  • -

#7 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: How to convert MS Access Database connection into MySQL Database?

Posted 27 April 2011 - 02:02 PM

very good sir. Keep that connectionstrings site in mind for future.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1