Results 1 to 4 of 4

Thread: Connecting to Online MySQL Database

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    258

    Connecting to Online MySQL Database

    I got this Database that is Online thats hosted through the Website and uses MySQL, and the Tables have some Data I like to Read From. Heres what I got (I used Jim's Data Read Thread)

    vb Code:
    1. Public Sub testconnect()
    2.         Dim sqlconn As String = "Server=63.247.93.106;Database=viina_schoolbook;User=---; Password=---;"
    3.         Using Connection2 As New SqlConnection(sqlconn)
    4.             Using commanda As New SqlCommand("SELECT Keys From viina_schoolbook", Connection2)
    5.                 Connection2.Open()
    6.                 Using reader2 As SqlDataReader = commanda.ExecuteReader()
    7.                     While reader2.Read()
    8.                         MsgBox(reader2("keys"))
    9.                     End While
    10.                 End Using
    11.             End Using
    12.         End Using
    13.     End Sub

    When I tried doing this as the SQL Connection String:

    Driver={MySQL ODBC 3.51 Driver};Server=data.domain.com;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;

    I got an Error saying Driver is Invalid.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Connecting to Online MySQL Database

    Here's a quote from the first paragraph in that thread of mine:
    This code uses members of the System.Data.SqlClient namespace. If you're not using SQL Server then it's a simple matter of switching to the corresponding types of the appropriate namespace for your data source. For example, if you're using an Access database then you'd use an OleDb.OleDbConnection rather than an SqlClient.SqlConnection.
    You're not using SQL Server so you can't use the members of SqlClient. You're using an ODBC connection string for MySQL so you would need to use members of the System.Data.Odbc namespace with it.

    That said, I'd tend to recommend OleDb over Odbc and a MySQL-specific connector over OleDb. You can download one from the MySQL web site. Note that each different connector requires a different connection string format.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Addicted Member
    Join Date
    Dec 2006
    Posts
    207

    Re: Connecting to Online MySQL Database

    Have you installed the Driver on your server? If not, you can get the ODCB from MySQL.com

    http://dev.mysql.com/downloads/conne...5.1.html#win32
    Last edited by TURKINATOR; Feb 4th, 2009 at 01:53 PM.
    Rate me if my response helped you. If not, I accept charity Rates as well.

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Connecting to Online MySQL Database

    Hey

    If you are wanting to use the MySqlCommand, MySqlConnection objects etc, I think I am right in saying that you are going to need to install the Connector/Net, which you can download from here:

    http://dev.mysql.com/downloads/connector/net/5.2.html

    And you can find examples usage of this both here:

    http://dev.mysql.com/doc/refman/5.0/...qlcommand.html

    And here:

    http://www.vbmysql.com/articles/vbnet-mysql-tutorials

    Hope this helps!!

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width