Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connect to MYSQL

Status
Not open for further replies.

ArizonaRedneck

Programmer
Oct 25, 2004
61
US
I'm trying to connect to a mysql database. I'm using ByteFX. I added a reference of ByteFx to the project and use the following code:

Dim strConnectionString As String = "Data Source=mysql17.secureserver.net;" _
& "Database=*name here*;" _
& "User ID=*ID here*;" _
& "Password=*Password here*;"

Dim dstDataset As New DataSet()
Dim tblUsers As DataTable
Dim drwUserRow As DataRow
Dim strCommand As String
strCommand = "SELECT UserName from Users"
Dim darAdapter As New ByteFX.Data.MySqlClient.MySqlDataAdapter(strCommand, strConnectionString)
darAdapter.Fill(dstDataset, "Users")
tblUsers = dstDataset.Tables("Users")

For Each drwUserRow In tblUsers.Rows
Response.Write(drwUserRow("UserName"))
Next

I get the following error:
"Unable to connect to any of the specified MySQL hosts"
I've used similar code to connect to sql server and never had any problems. I'm not sure if it's my connection string or just ByteFX... Please Help!
 
thanks for replying Veep. I checked out the links and changed the connection string around according to what they suggested, but can't get it to work still. The current version is:

Dim strConnectionString As String =
"User ID=*UserName*" & _
"Password=*Password*;" & _
"Host=mysql17.secureserver.net;" & _
"Port=3306;" & _
"Database=*DatabaseName*;"

I still get
"Unable to connect to any of the specified MySQL hosts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top