I have some problems with a vb.net application.
My application was perfectly working on XP, but now on my windows 7, each time I want to connect to localhost, I have a driver problem (in french, that's why I don't put it here)...
Do you know were does it come from?
My odbc driver is up to date...
Download and install Connector/.NET.
In your project, you should be able to add a reference to MySql.Data. You can then create your connection string.
Dim oMySqlConn As MySqlConnection = New MySqlConnection()
oMySqlConn.ConnectionString = "Data Source=localhost;" & _
"Database=mySQLDatabase;" & _
"User ID=myUsername;" & _
"Password=myPassword;" & _
"Command Logging=false"
oMySqlConn.Open()
localhost can be replaced with either an IP address or 'servename.com'
Related
I'm trying to establish an ADO connection between excel on my local machine and a MySQL database on my server.
In the examples I've seen (here and here, for instance) there's a driver of the form MySQL ODBC 5.x Driver. It seems that after installing the latest mysql connector / odbc download (32-bit, to match my msexcel) the relevant registry driver files HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Driver\ are now named 'SQL Server' and 'SQL Server Native Client 11.0.' I'm not having success establishing a connection to MySQL with either of these.
My VBA
Sub connect()
Dim Password As String
Dim SQLStr As String
Dim Server_Name As String
Dim User_ID As String
Dim Database_Name As String
Set rs = CreateObject("ADODB.Recordset") 'EBGen-Daily
Server_Name = "184.154.225.243"
Database_Name = "*******" ' Name of database
User_ID = "********" 'id user or username
Password = "*******" 'Password
Port = "3306"
SQLStr = "SELECT * FROM *******"
Set Cn = CreateObject("ADODB.Connection")
Cn.Open "Driver={SQL Server};Server=" & _
Server_Name & ";Port=" & Port & ";Database=" & Database_Name & _
";Uid=" & User_ID & ";Pwd=" & Password & ";"
rs.Open SQLStr, Cn, adOpenStatic
Upon running the above, I receive error [Microsoft][ODBC SQL Server Drive][DBNETLIB]SQL Server does not exist or access denied. The error for the 'native client 11.0' driver is Could not open a connection to SQL Server[53].
I've tested the connection parameters in MySQL workbench and all is functional. What's going on?
Check if you are using the 32 bit or the 64 bit version of Microsoft Office.
Based on the above, download and install the appropriate MySQL driver from the download link
Once the ODBC driver installation is complete, check the ODBC snap in to see the driver is listed as installed.
If you are using a 32 bit OS, then everything is 32 bit. Use Run -> odbcad32.exe -> Drivers tab.
If you are using a 64 bit OS, and Microsoft Office is 32 bit, then use c:\windows\syswow64\odbcad32.exe -> Drivers tab.
If you are using a 64 bit OS, and Microsoft Office is 64 bit, then use Run -> odbcad32.exe -> Drivers tab.
If the MySQL drivers are properly installed, they should appear as shown above
Create a System DSN using the ODBC snap in with the MySQL driver listed above and test the connection to see if it works.
Use the same parameters when you try to create an ODBC from within VBA.
Example:
Driver={MySQL ODBC 5.3 ANSI Driver};Server=localhost;Database=myDataBase;
User=myUsername;Password=myPassword;Option=3;
Once it is established that you can successfully create a connection to the MySQL server, then change the driver name in the registry (make sure to update both the registry keys) and try using the new name you give such as SQL Server.
Remember: On a x64 bit system for a x32 bit drivers:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers
A restart may be required after changing the driver name.
(From my research, Index Server no longer exists on Win2012 -- If this is mistaken, tell me how to set it up!)
Moving a nice .asp application from Win2003 server to Win2012. This app makes heavy use of Index Server via the OLE DB driver for index server.
Example of how we use it:
StrSQL="SELECT size, doctitle, vpath, filename, size, write, " & _
"characterization, path, rank FROM SCOPE() " & _
"WHERE CONTAINS('"searching words"') " & _
"AND vPath LIKE '%Knowledgestore%'" " & _
"AND (filename like '%TXT')" & _
"ORDER BY rank DESC"
Set ixQuery = Server.CreateObject("ADODB.Connection")
Set QueryRS = Server.CreateObject("ADODB.RecordSet")
ixQuery.Open "provider=msidxs;Data Source=knowledgestore"
QueryRS.Open strSQL,ixQuery
How do I do this against Microsoft Search Service?
Is there an OLE DB provider for Search Service?
If not, what is the appro way to access Search Service from VBA/ASP/Python?
use Provider=Search.CollatorDSO;Extended Properties='Application=Windows'; as connectionstring.
After lots of digging around, the answer has been found.
Downloading and installing Windows Search Server does not install the OLE DB provider. Neither does installing the Windows SDK. The provider is installed when the Windows Search Service is installed.
On Win7/8 desktop OS, this is installed by default (I believe). On server, you have to enable the feature.
Trying to implement Excel VBA: writing to mysql database.
Following code runs into a run-time error [MIcrosoft][ODBC Driver Manager] Data source name not found and no default driver specified
Dim cn As Object
Sub Connect()
Dim strCon as string
Set cn = CreateObject("ADODB.connection")
strCon = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=localhost;" & _
"DATABASE=dbname;" & _
"USER=root;" & _
"PASSWORD=mypass;" & _
"Port=3306;" & _
"Option=3"
cn.Open strCon
cn.Close
End Sub
checked connection parameters with the following php code
$mysqli = new mysqli('localhost','root','mypass','dbname');
and all works just fine.
I do have Microsoft ActiveX Data Objects 2.8 Library ticked in my VBA Project References.
Any help is welcomed.
For whatever it's worth at this point (since I just ran into it and it took me a day to figure it out):
You may have MySQL (or other Database/Application) in either 32 bit or 64 bit form.
You may have Excel (or other application) in either 32 or 64 bit form.
You may have the ODBC "connection" between the two in either 32 or 64 bit form.
Typically, the ODBC driver will be installed when you install the DB product, so it will be the same as the database.
Unfortunately, that's not important.
What IS important is that the ODBC driver match the application (e.g., Excel) properly.
If you have 32 bit Excel, and install 64 bit MySQL, that's fine, but Excel won't be able to connect to MySQL (except through the MySQL Connector, but that's not the goal here).
You won't be able to write an Excel app to read, via ODBC, from the database.
The solution is simple. Download the MySQL ODBC driver for 32 bit (same place as MySQL), and install it.
(It will tell you 'already installed' - because it will see the 64 bit version - and ask if you want to uninstall. Say Yes.)
Now, 32bit Excel can talk to 32bit ODBC driver, which can talk to 64bit MySQL, to exchange data.
Note: Far as I know, you can only install one type of ODBC driver (per DB App). So, if you are using the 64bit version, perhaps for some other app, you'll have to uninstall it (which breaks access to that App) to install the 32bit version so you can use Excel.
I have a 64 Win machine with 32bit Excel. I experimented with different MySQl ODBC drivers (5.1, 5.2, 5.3). The 64bit drivers did not work fro me, but the 32bit odbc driver did work.
Somewhere in the Microsoft knowledgebase it mentioned that Excel does not work with the 64bit drivers.
I recommend using a more recent one than the one you mentioned in your post:
http://dev.mysql.com/downloads/connector/odbc/5.2.html
This vba code worked for me
Set oConn = New ADODB.Connection
With oConn
.ConnectionString = "Driver={MySQL ODBC 5.2 Unicode Driver};" & _
"Server=" & strServer & ";Port=3306;" & _
"Database=" & strDBName & ";" & _
"Uid=" & strUserID & ";" & _
"Pwd=" & strPasswd & ";Option=3;"
.open
end with
OK, so I've read this identical question, but the answers don't work for me:
Connecting VB6 and MS Access 2007
I've removed the reference to Microsoft DAO 3.6 Object Library, and replaced it with a reference to Microsoft Office 12.0 Access database engine Object.
Here's my code:
Dim rcdSetData As ADODB.Recordset
Set rcdSetData = New ADODB.Recordset
rcdSetData.CursorType = adOpenStatic
rcdSetData.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0; " _
& "Data Source=" & DBName & "; "
I can open Access 2003 *.mdb files just fine, but when I try to open an Access 2007 *.accdb file, I get:
Error #blahblah, Unrecognized database format 'C:\path\foo.accdb'
foo.accdb is a valid Access 2007 file, as far as Access 2007 cares. No password, BTW, and it isn't open in Access when I run the program.
I'm stumped. EVERY answer I can find on the web says I'm doing this right.... :\
The DAO reference (be it to the pre- or post-Access 2007 version of that library) is irrelevant, since your VB code is using ADO instead. Your problem lies rather with the connection string. Try replacing
"Provider=Microsoft.Jet.OLEDB.4.0; " _
with
"Provider=Microsoft.ACE.OLEDB.12.0; " _
If you have recently re-installed VB6, make sure you download and install the service pack SP6 for it.
I got a hosting plan from GKG.net and I have a VB6 connection string to remotely reach MySQL database in it. I followed all instructions and tutorials about how to reach MySQL server remotely. Everything was fine till i get an error that says:
[MySQL][ODBC 3.51 Driver] Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (10060)
I searched for a solution over the net for hours but still there is nothing makes sense about it.. I double checked my connections.. I can ping to my static ip, but cant reach the MySQL server in it.
From CPanel i can reach my db with phpMyAdmin. I tested my db and there was nothing wrong with it. Everything seems right. Except i still get the error message with VB6
My connection string:
Dim conn As ADODB.Connection
Dim constr As String
Private Sub OpenServer()
Set conn = New ADODB.Connection
constr = "Driver={MySQL ODBC 3.51 Driver};" & _
"PORT=" & db_port & ";" & _
"SERVER=" & db_server & ";" & _
"DATABASE=" & db_name & ";" & _
"UID=" & db_user & ";" & _
"PWD=" & db_pass & ";" & _
"OPTION=3;" & _
"STMT=;"
conn.Open constr
End Sub
So how can i resolve this damned connection issue? and
What are the odds that causes this?
Hosts where you access their database server very rarely allow remote access to the database from outside their hosting environment (I have never seen it).
If you setup the MySql database yourself (on a dedicated or virtual server plan) then you should be able to set it up to accept remote hosts. In that case you need to modify your my.con file to allow remote hosts (you can also do it via the MySql Admin tools) and you need to grant the login you are trying to use access from the remote IP:
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
Your previous comment about SQLyog is a very good idea. And I can vouch for that product. It is a great tool. The free admin tools from MySql (Workbench - http://www.mysql.com/downloads/workbench/) are also decent and will allow you to test remote access as well.
check this Solution to Connecting remotely when you get Error 10060
http://forums.mysql.com/read.php?34,49742,239961
http://www.bigresource.com/VB-Remote-MySQL-Server-h6Z8Cbaszz.html#
MySQL is setup to handle remote connections very easily. However, you must setup MySQL to allow your users in. The other thing to do, is make sure port 3306 is open on the host. If it is not, then you can't connect to MySQL. The easiest way to do this is to...
telnet myhost 3306
If you get something back like...
,
3.23.54-log▬I_&:309i☻
then port 3306 is open and MySQL is listening.
Next, make sure your userid is setup to allow access on the MySQL server. You can do this with the mysql client software, or the mysqlcc software.
Hope this helps
I had this problem. I could connect from localhost but not from a client computer. I turned off Windows firewall (windows 8). However, no joy. I then created a new rule in firewall advanced settings and BINGO it worked. The new rule just allowed incoming connections on port 3306 on my private network.
Another approach for VB6. I use it like this in all my apps and its been working for years.
Dim StoreDB As ADODB.Connection
On Error Resume Next
Set StoreDB = New ADODB.Connection
StoreDB.Open "Driver={MySQL ODBC 3.51 Driver};Server=000.000.000.000;Port=3306;Database=yourDBName;User=Someusername;Password=Somepassword;OPTION=8;"
If Err.Number = 0 Then
[VB6 Code to execute]
Else
myErrorString = Err.Description
End If
StoreDB.Close
Set StoreDB = Nothing
As mentioned, ensure port is 3306. I have a host that uses 3307. I see no problem with your code. You probably need to sort this with the host.
Add mysqlid.exe into your windows firewall settings to access your server remotely