Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a VB Expert!

Join 244,310 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 864 people online right now. 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
3 Jul, 2008 - 07: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
+Quote Post


PsychoCoder
RE: Can Not Connect To SQL Database
3 Jul, 2008 - 09:52 AM
Post #2

loves.Coding(this);
Group Icon

Joined: 26 Jul, 2007
Posts: 12,288



Thanked: 372 times
Dream Kudos: 10775
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

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
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 07:18PM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month