Results 1 to 14 of 14

Thread: [RESOLVED] Hostgator connection string ?

  1. #1

    Thread Starter
    Addicted Member t3cho's Avatar
    Join Date
    Mar 2014
    Posts
    234

    Resolved [RESOLVED] Hostgator connection string ?

    I created the mysql database via phpmyadmin at hostgator.com hosting .
    Using mysql connector to work withdatabase and i stuck i don't know how to make a connection string ?

    I'm trying like this

    Code:
      mysqlconnection.ConnectionString = "server=hostgator.com; Port=3306; user id=myID; password=myPW; database=myDB"
    But it allways says that i cannot connect to database. Entire code downthere.

    Code:
     Try
                mysqlconnection = New MySqlConnection
                mysqlconnection.ConnectionString = "server=hostgator.com; Port=3306; user id=myID; password=myPW; database=myDB"
                mysqlconnection.Open()
            Catch ex As Exception
    
            End Try
    
    
            Dim sqlquiery = "SELECT id, nmbr, used, cpuid FROM teacher_keys.teacher;"
            Dim command As New MySqlCommand
            Dim myadapter As New MySqlDataAdapter
    
            Try
                command.Connection = mysqlconnection
                command.CommandText = sqlquiery
                myadapter.SelectCommand = command
                myadapter.Fill(ds, "baze3")
            Catch ex As Exception
                MsgBox("Error! You are not connected with database.", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Error")
            End Try

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,538

    Re: Hostgator connection string ?

    You'll need to get the connection information from them. A couple things to keep in mind:
    * Server isn't likely to be hostgator.com, it's likely to be something else.
    * you'll need to know if the db servers are behind a firewall or if they are exposed publicly to the web.
    IF the db server is behind a firewall (which any respectable host will have) then you're not going to be able to directly access it from outside their network. If that's the case, you're going to need to change your approach. If the db IS open to the interwebs and you can direct connect, you just need the right connection info.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Addicted Member t3cho's Avatar
    Join Date
    Mar 2014
    Posts
    234

    Re: Hostgator connection string ?

    Quote Originally Posted by techgnome View Post
    You'll need to get the connection information from them. A couple things to keep in mind:
    * Server isn't likely to be hostgator.com, it's likely to be something else.
    * you'll need to know if the db servers are behind a firewall or if they are exposed publicly to the web.
    IF the db server is behind a firewall (which any respectable host will have) then you're not going to be able to directly access it from outside their network. If that's the case, you're going to need to change your approach. If the db IS open to the interwebs and you can direct connect, you just need the right connection info.

    -tg
    Hmh to much to learn from now on. I thought it will be easy as before.

    Code:
    mysqlconnection.ConnectionString = "server=db4free.net;Port=3306; user id=bwun; password=bpw; database=bdb"
    Connection string from db4free website.

  4. #4

    Thread Starter
    Addicted Member t3cho's Avatar
    Join Date
    Mar 2014
    Posts
    234

    Re: Hostgator connection string ?

    I contacted hostgator support they said i have those details at bottom of page.

    Down there i have only

    IP Address xxx.xxx.xx.xxx
    Server Name gator4147

    I searched a bit and when i opened one link it shown me like this
    https://gator4147.hostgator.com:2083

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,538

    Re: Hostgator connection string ?

    you shouldn't be getting nothing. You should be getting something... either a connection, data, or an error message. But you will get something.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Addicted Member t3cho's Avatar
    Join Date
    Mar 2014
    Posts
    234

    Re: Hostgator connection string ?

    Quote Originally Posted by techgnome View Post
    you shouldn't be getting nothing. You should be getting something... either a connection, data, or an error message. But you will get something.


    -tg
    always the same error

    Error! You are not connected with database.

  7. #7
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,538

    Re: Hostgator connection string ?

    That's not the error - that's your error message, but that's not the error. You should be getting a legit error message. I also notice your connection is wrapped up in a Try Catch with an empty catch... which means there could be an error happening there, but you'd never know because you chose to ignore it. What you have is the .NET equivalent of On Error Resume Next.

    During development you should either 1) use try catch only very limitedly so you can see where things go wrong or 2) make sure you display meaningful messages so that you know what is wrong.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    Addicted Member t3cho's Avatar
    Join Date
    Mar 2014
    Posts
    234

    Re: Hostgator connection string ?

    Quote Originally Posted by techgnome View Post
    That's not the error - that's your error message, but that's not the error. You should be getting a legit error message. I also notice your connection is wrapped up in a Try Catch with an empty catch... which means there could be an error happening there, but you'd never know because you chose to ignore it. What you have is the .NET equivalent of On Error Resume Next.

    During development you should either 1) use try catch only very limitedly so you can see where things go wrong or 2) make sure you display meaningful messages so that you know what is wrong.

    -tg
    Thanks for your answer.

    So basically i just need to test am i able to connect to a database how would i do that ???

    If can't connect to a database to show me an msgbox
    Code:
    Dim mysqlconnection As MySqlConnection
    mysqlconnection = New MySqlConnection
    mysqlconnection.ConnectionString = "server=hostgator.com; Port=3306; user id=myID; password=myPW; database=myDB"
    mysqlconnection.Open()

  9. #9
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,538

    Re: Hostgator connection string ?

    That's how you would do it... make the connection... if there is an error, let it be displayed, don't cover it up with your own message... at least for now... later if you want, add in the message box.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10

    Thread Starter
    Addicted Member t3cho's Avatar
    Join Date
    Mar 2014
    Posts
    234

    Re: Hostgator connection string ?

    Quote Originally Posted by techgnome View Post
    That's how you would do it... make the connection... if there is an error, let it be displayed, don't cover it up with your own message... at least for now... later if you want, add in the message box.

    -tg

    I did this code in Form Load event and it didnt show any errors :S
    What am i making wrong now.

    Code:
    Imports MySql.Data.MySqlClient
    Public Class Form1
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim mysqlconnection As MySqlConnection
            mysqlconnection = New MySqlConnection
            mysqlconnection.ConnectionString = "server=hostgator.com; Port=3306; user id=myID; password=myPW; database=myDB"
            mysqlconnection.Open()
        End Sub
    End Class

  11. #11
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,538

    Re: Hostgator connection string ?

    Yeaaah... that's another issue all together. There's a wonderful "feature" in 64-bit windows that causes exceptions to be swallowed up in the FormLoad event...

    The WIndows group sees it as a feature - it prevents applications from breaking on startup. Just about everyone else in the development world sees it as a bug. It's also not going to change any time soon.

    Just throw together a quick app with a button and put the code in the click event of the button.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  12. #12

    Thread Starter
    Addicted Member t3cho's Avatar
    Join Date
    Mar 2014
    Posts
    234

    Re: Hostgator connection string ?

    Ok then.

    It says unable to connect to mysql host

    Name:  e92123818293f39264873a45db0fdddf.jpg
Views: 2326
Size:  18.5 KB


    Edit: This one

    {"Authentication to host 'gator4147.hostgator.com' for user 'user' using method 'mysql_native_password' failed with message: Access denied for user 'user'@'%' to database 'database'"}

  13. #13

    Thread Starter
    Addicted Member t3cho's Avatar
    Join Date
    Mar 2014
    Posts
    234

    Re: Hostgator connection string ?

    Problem Solwed:

    The problem was in that i created the database and the user, and i didnt assign user to that database.

    Thank a lot -tg you helped me and learned that Custom messages aren't allways the right choice

  14. #14
    Registered User
    Join Date
    Mar 2015
    Posts
    9

    Re: [RESOLVED] Hostgator connection string ?

    The problem was in that i created the database and the user, and i didnt assign user to that database.
    Thanks. I think this has happened a lot on HG users as well. They may need to include this on their KB site too.

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