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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL connection

Status
Not open for further replies.

byleth

Programmer
Feb 27, 2004
70
PT
Hi,

I'm having a problem when trying to connect to a MySQL database, here's the relevant code:


1:Imports System.Data.OleDb
.
.
.
2: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


3: Dim myConnString As String = "Provider=SQLOLEDB;Data Source=db;User Id=abc;Password=xyz; Integrated Security=SSPI;"
4: Dim myConnection As New OleDbConnection(myConnString)

5: myConnection.Open()

.
.
.


At line 5 i get:

"An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll"



I'm using:

MS VB .NET 2002
MS .NET Framework 1.0
MySQL Server 5.0
MySQL ODBC 3.51 Driver

The parameters to the myConnString at line 3 are all correct, and the database itself is working properly
I really don't know what i'm doing wrong here..
Thanks in advance
 
If you are using ODBC, you will have to use ODBC.Net, not OLEDB
 
No, i'm using oledb, forget about the MySQL ODBC 3.51 Driver...
 
And according to this site youre connectionstring is all wrong.


it should be something like this

conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};"_
& "SERVER=localhost;"_
& " DATABASE=test;"_
& "UID=venu;PWD=venu; OPTION=3"

the connectionstring you are using is one that is used for sqlserver. There is only a small change mysql would be using SSPI.
Ofcourse its also possible that you are getting a SSPI context error.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
And BTW you do need ODBC.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top