Connecting to remote mySQL via Excel VBA - mysql

Likely a dumb question but brain isn't piecing this together---
tl;dr: My main question is how do I choose the right parameters for my connection string? How do I determine what my driver should be? Provider? Option? Where do I find a list of acceptable parameters? How do I choose between ADO and OLE?
Objective: to connect to a hosted mySQL db of which I am admin.
Problem: creating a successful connection string / choosing the right parameters.
I'm new to referencing remote databases. Been looking all day today and yesterday; there are tons of articles and posts out there but nothing is working for me--I'm just trying to replicate what I see being done when I need to just design the string properly, but I don't know where to start.
I've tried using ActiveX Data Objects 2.7, 2.8 and 6.1 libraries. Also tried using OLE DB Simple Provider 1.5 Library. Below tests are using ADO 6.1.
Tried these connection strings:
DRIVER={MySQL ODBC 5.3 Unicode Driver};SERVER=ipaddress;PROVIDER=SQLOLEDB;DATABASE=xxx;UID=xxx;PWD=xxx;
---Error: waits ~30 seconds, times out and says Invalid Connection String Attribute
DRIVER={MySQL ODBC 5.3 Unicode Driver};SERVER=ipaddress;PROVIDER=Microsoft.Jet.OLEDB.4.0;DATABASE=db_name;USER=xxx;PASSWORD=xxx;
---Error: immediately errors and says cannot find installable ISAM
SERVER=ipaddress;PROVIDER=SQLOLEDB;DATABASE=xxx;UID=xxx;PWD=xxx;
---Error: waits ~30 seconds, times out and says SQL Database does not exist or access denied
I'm sure i've added the correct user with password and permissions. I haven't done anything with DSN.
I'm on win8.1 x64 using Excel 2013. Any advice is much appreciated!!

Related

ERROR [3D000] [MySQL][ODBC 5.3(w) Driver][mysqld-5.7.9]No database selected

I've got WampServer running a local instance of WordPress, and I have SSRS running in native mode.
I've written a report that queries the MySQL database, and it works and runs just fine within Visual Studio.
If I launch it though, it first had issues with my ODBC shared data source, which was as follows:
Name of shared data source: localhost.rds
ODBC Connection string: Dsn=localhostuserDSN
That DSN is a user DSN (as you might've guessed), and it uses the MySQL ODBC 5.3 Unicode driver. It's configured as follows:
TCP/IP server: localhost
Port: 3306
User: root
Password: <blank>
Database: wp
When tested, the connection succeeds, and the report works just fine.
When deployed though, I got the following error:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
After much research and hair-pulling, I finally found out that if I changed the data source connection string to...
Dsn=localhostUserDSN;Driver=MySQL ODBC 5.3 Unicode Driver
...that also works, and at least then, the connection also succeed when in the Data Sources configuration screen for the report after it's deployed. But then, just when I thought I was finally out of the woods, I run the report and get the following error message:
ERROR [3D000] [MySQL][ODBC 5.3(w) Driver][mysqld-5.7.9]No database selected
The thing is, I can't specify a database, or at least I don't know a way to.
If I try changing the connection string to...
Dsn=localhostUserDSN;Driver=MySQL ODBC 5.3 Unicode Driver;database=wp
...it says the (blank) password isn't valid, before I've even pressed the 'Test' button.
If I tack on 'USE [wp]' to the query in Visual Studio, it abruptly protests.
I thought maybe I'd get around that by putting it in a stored procedure, but since the data is being queried directly from the MySQL database, I can't do that either.
(Before attempting any of this, I already tried syncing/converting the MySQL db to the SQL db, but I kept running into issues with the data conversion.)
Thinking it might be a permission issue, I've also tried running...
GRANT ALL ON [wp] TO root#localhost;
...and...
GRANT ALL PRIVILEGES ON [wp] TO root#localhost;
in SSMS, but in both cases, it says:
Cannot find the object 'wp', because it does not exist or you do not have permission.
And I'm the only admin on a local machine. I installed SQL and it uses Windows Authentication, so I don't see how I wouldn't have permission, and I have to assume it's an issue with the syntax.
I saw elsewhere here that someone suggested '[wp].*', but it doesn't like that either.
I've been at this literally all day, and I'm at my whits end, so any constructive feedback would be greatly appreciated!
For anyone stumbling across this in the future, I think we resolved the original issue, although I've run into other issues which may be specific to me.
Three things, not sure if the first one is related:
1) In the query for the dataset of the report, I specified the table like so "SELECT wp_posts.ID FROM wp_posts" instead of just "SELECT ID FROM wp_posts".
2) I went back to adding on "database=wp" to the ODBC connection string.
3) Even though both work in Visual Studio, I switched to a System DSN instead of the User DSN.
I think that should get you back in action.

Problems importing MySQL data into Access 2010

I have a small database with 10 tables in it - of those, 6 import directly into Access via an ODBC connection to a MySQL database without any issue. However, 4 of them throw an error: "Could not open the object"
The MySQL ODBC driver is 3.51 -- anything greater didn't work at all and it was suggested on the MySQL.com support site to use 3.51 instead.
I can also import these into Excel without any trouble... so I am not sure if the issue is with Access or the ODBC driver..
I've seen this issue happen with MySQL tables containing field types that Access/Jet doesn't understand and that the MySQL ODBC driver doesn't fully translate enough for Access to map to a known field type (to Access). I know it's been a bit of time - but do you think you could post a description of your table(s) that are having trouble? Perhaps you could get more MySQL/Access people in here answering your issue (if I can't, that is).

Importing Entity Database Model from MySQL to Visual Studio 2010

Im trying to get Entity Data Model with wizard from remote MySQL server. I'm typing proper connection string, then choose next. I see all tables, i can check them. When wizard finished im getting no entity models and this errors:
Unable to generate the model because of the following exception: 'The provider did not return a ProviderManifestToken string.
Access denied for user 'myserver'#'myIP' (using password: NO)
P.S. Server Explorer and database sets working fine, I can write/read table data.
Environment:
Database:
Windows 2008 Server R2 (Enterprise)
MySQL Workbench 5.2
MySQL Connector Net 6.4.4
Client:
Windows 7 64bit Professional
Visual Studio 2010
MySQL Connector 6.4.4
.NET Framework 4
My Connection String:
metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=MySql.Data.MySqlClient;provider connection string="server=myserver;User Id=myID;database=myDatabase;password=myPassword"
I ran into similar issues. The connection string was good, and I could grab data from my application, server browser, etc. But whenever I tried to update the schema, the Entity framework would ignore the password in the config.
Workaround - Temporarily give the anonymous user all the necessary permissions on your mysql instance (in my case, local to my machine, so no security threats) and run the model update from Visual Studio. This way, a password won't be necessary.
Once all the entities are updated, go back and revert the permissions to the way they were.
It's not ideal, and I still don't know what the issue is, but it got me past the problem.

Sharepoint Designer 2007 ODBC database connection to MySQL impossible?

I'm trying to create a Database Connection to ODBC data sources in SPD 2007 and am having absolutely no luck. I've had some success using an SqlDataSource control, however. I don't know if SPD's database connection support is just broken or what. Googling has turned up others having issues but no definitive answers.
So, my two data sources are MySQL 5.1 ODBC and ProvideX ODBC. I pretty much have the same trouble with either, so I'll just focus on MySQL.
I've got a system DSN on the machine running SPD that is successfully connecting to the MySQL database. (This DSN also exists on the server running Sharepoint, if that matters at this time).
In SPD, I go the Data Source Library, expand Database Connection, and choose Connect to a Database. I then click on Configure Database Connection. Since neither of the providers in this dialog are appropriate, I choose "Use a custom connection string". I then set the provider to "Microsoft .Net....ODBC" and at this point I've tried the following connection strings.
First the DSN attempts:
Dsn=TheOneICreated (this one works from the SqlDataSource control)
and
Data Source=TheOneICreated
Then the more direct approach:
Driver={MySQL ODBC 5.1 Driver};Server=myServerIP;Database=dbName;User=username;Password=password;Option=3
The error I get back is always the same -
"Server Error: An error occurred while
retrieving the list of Databases from
: The server for the data source
returned a non-specific error when
trying to execute your query. Check
the format and content of your query
and try again. If the problem
persists, contact the server
administrator."
Am I fighting a losing battle here?
It looks like SD could be enumerating databases and/or tables so it has a list of tables and fields to 'help' you along....
Just a clarifying question or two..
Could this happen because SD is expecting a different way of enumerating tables? (Does it actually work with MySQL or anything ?)
What does your ODBC trace look like? (If #1 is true, you'll be able to see it and possibly create supporting views...if you truly need it to work with this particular dbms...)
Is this connection accessed from the sharepoint server? If so, do you need to define your dsn & driver there?

Migrating from MS SQL to MySQL: SQLOLEDB? Migration kit login error?

I've been put in charge of migrating a customer's website of MS SQL/ASP to PHP/MYSQL. I have zero experience with MS SQL.
I'm trying to figure out the best way to get the current data migrated to MySQL so I can begin PHP development.
Some details:
I downloaded SQL Server Mangement Studio Express. I found the following string in a connection file:
MM_connCompanyName_STRING = "provider=SQLOLEDB;data source=IP_ADDRESS;database=DATABASENAME;uid=USERNAMEpwd=PASSWORD;"
Using the IP, username, and password from this string, I could successfully connect using Studio Express.
I downloaded the MySQL Migration Toolkit and entered the same info, but get the following error:
Connecting to source database and retrieve schemata names.
Initializing JDBC driver ...
Driver class MS SQL JDBC Driver
Opening connection ...
Connection jdbc:jtds:sqlserver://IP_ADDRESS:1433/DATABASENAME;user=USERNAME;password=PASSWORD;";charset=utf-8;domain=
The list of schema names could not be retrieved (error: 0).
ReverseEngineeringMssql.getSchemata :Login failed for user 'USERNAME'.
I don't have admin or physical access to the current SQL server. I've tried to run some exports through Studio Express, but it saves them to the file system, which I don't have access to.
I can reach the current/old webmaster, but because he no longer works for the company, his responses are slow and usually un-helpful. So no help there...
The former admin sent me an MDF file ... no idea what to do with that.
I found this note above the connection info on the current server (if it means anything):
'this connection is being used because
ODBC was causing weird errors,
switching to OLEDB fixed them
My questions:
Any idea why this would be failing with the same login credentials that works with Studio Express? I'm assuming it has something to do with the driver, but I don't know what next steps to take.
Is there a better/easier/more effective way to migrate this data? (I'm hoping I don't find myself running "SELECT *" statements in Studio Express and copy/pasting data into Excel...please god, no)
Thanks in advance for your help.
Eww, this is going to be scary (connection string indicates it was tool generated from Dreamweaver, never a good sign).
Any idea which version of SQL Server? You should be able to SELECT ##VERSION. 10.x is 2008, 9.x is 2005 and 8.x is 2000. If it is 7.x run.
The MDF file is the actual database. If I were you, I would buy a developer edition of SQL 2005 (or 8 if it is 2008 which is unlikely), it will be worth the $99 or so it costs.
This will give you the ability to locally install the DB by ATTACHing the MDF file. Once you have a locally running copy, you can use the SQL Server ETL tools with the MySql ODBC drivers to push the data to MySql in a repeatable manner.
I believe you can export data from MSSQL choosing different SQL dialects; I believe there's one that's reasonably MySQL compatible. It doesn't solve all your problems, of course, because while you may get the structure properly, stored procedures and triggers and the like will take a bit more work. But that should get you started.