Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 109,373 VB Programmers for FREE! Ask your question and get quick answers from experts. There are 986 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Can not connect to SQL database

 
Reply to this topicStart new topic

Can not connect to SQL database

MrFlow
post 3 Jul, 2008 - 08:37 AM
Post #1


New D.I.C Head

*
Joined: 3 Jul, 2008
Posts: 1

Hello everybody,

I am trying to connect to a MySQL database from an Visual Basic Excel macro, but I can not make it.

I have done it like it is described here:
http://www.dreamincode.net/forums/showtopic24677.htm

My code:

CODE

Dim sqlConnection As New ADODB.Connection
Dim sqlRecordset As New ADODB.Recordset

sqlConnection.Open "Provider=SQLOLEDB;Data Source=<IP>;Initial Catalog=<DatabaseName>;User Id=<User>;Password=<Password>;"

'...


The program is doing something in the "open" line, but comes back with an error. Message: "[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied."

I am not so sure about the connection string, especially about the provider. Used values(<>) are ok. I can connect via MySQL Query Browser.

MySQL-Version: MySQL 4.1.10a-log via TCP/IP

Has anybody an idea what I am doing wrong or what is missing?

Thanks

MrFlow
User is offlineProfile CardPM

Go to the top of the page


PsychoCoder
post 3 Jul, 2008 - 10:52 AM
Post #2


DIC.Rules == true;

Group Icon
Joined: 26 Jul, 2007
Posts: 7,241



Thanked 52 times

Dream Kudos: 7775

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, GDI, Boo.Net

My Contributions


To connect to mySQL you will first need the mySQL ODBC Driver and the Microsoft Remote Data Object. Once you have that here is a VB6 example of connecting to a mySQL database


vb

Dim mySqlConn As New rdoConnection
Dim query As New rdoQuery
Dim mySqlRecordSet As rdoResultset


mySqlConn.CursorDriver = rdUseOdbc

'Make sure to change the username & password as well
'as the database in this connection string
mySqlConn.Connect = "uid=YourUserName;pwd=YourPassword;
server=YourServerName;" & _
"driver={MySQL ODBC 3.51 Driver};
database=YourDataBase;dsn=;"
mySqlConn.EstablishConnection



Hope that helps smile.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/6/08 11:37PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month