QODBC connection string format - mysql

I am trying to learn about databases and my most current challenge is connecting from my iOS machine using qt5 into a database through the QODBC driver. After a bit of goggle-ing sure enough I found a bunch of threads on the subject and I now realise that in order to get rid of my
"QODBC3: Unable to connect" "[iODBC][Driver Manager]Data source name not found and no default driver specified. Driver could not be loaded"
error I must specify a connection string like such
db->setDatabaseName("Driver={SQL Server Native Client 11.0};Server=*<ip/host>*;Database=*<database>*;Uid=*<userid>*;Pwd=*<password>*;"
But I still can't make this work, because I am not sure what should I put as a Driver value. Where is this driver, or what if my database server is on another computer inside my Lan?

The QODBC driver adds a windows DSN. They are quite clever about preventing access from processes not running on the Quickbooks computer unless you buy their $499 server version.
I access the QODBC driver from within PHP command line, I first allow the odbc php module and use this in my PHP script:
$qb = odbc_connect("Quickbooks Data", "", "");
I did experiment with running a PHP script as a service, connected to a port which would then listen for incoming queries and reply with the result.
This worked, but ultimately we moved Quickbooks out of the workflow we use interacting with customers. Quickbooks is too unreliable for mission critical processes (example: taking money from customers); multiple times something would happen, Windows or UPS would update, and then our automated workflow for shuffling customer data and charging credit cards would fail.

Related

Send data to a MySQL server over an internet connection

I'm a total beginner to MySQL, I'm more of a firmware specialist. I'm working on an application where I will be getting GPS coordinates from a microcontroller + cellular device and I would like some way to store the coordinates and do processing on them. I figured a database hosted on a server made the most sense, which is what has brought me to MySQL.
Basically, I'm wondering what the basic protocol is for sending data to a MySQL server over an internet connection (my device has data). Like how do I connect to the server and publish data to it?
I'm experienced with MQTT and I think I could do TCP as well but I'm looking for a protocol that is not super power-intensive and I can't use anything that requires an operating system, like a python script.
To be clear, I am NOT asking you to tell me every step for how this is done, but basically what protocol and what tools could I use? Anything you can tell me would be appreciated.
I was thinking that I could use the MySQL client C code to help write a driver that could allow me to connect to the server. I'm experienced with writing drivers and the microcontroller I'm using uses C.
You need no direct connection to the DB at all. Your cellular device should be able to establish tcp connection to the ipaddress/port and to send the byte-stream through the connection. It can be the dumb unidirectional protocol with losses.
You need some service that can listen on the other side, that can parse your byte-stream, can fetch the correct packets from it and then send the data to the database. Speaking frankly that service can even be written in linux shell:
nc -lk 1234 | collector.sh
where collector.sh is a script like that:
#!/bin/sh
while read LINE
do
# $LINE parsing and all the staff
mysql -e "INSERT INTO mygps.nmea (lat,lon,dtime) VALUES ($LAT, $LON, $DTIME);"
done <<< /dev/stdin
####
Sure it isn't a best solution but it was really helpful for me at the very beginning. Then you can proceed the gathered data in any desired way.
Build a simple server that communicates with whatever gathered data and then use the server so send the data to MySQL with the help of MySQL connector. Building part of the protocol will quite time consuming. - nbk
If you "can't use anything that requires an operating system" you need some middleware that can run the MySQL client driver to talk to the database, you will then use MQTT to pass data between your sensor and the middleware. If you don't want to write this middleware yourself, something like Node-RED might come handy.
You certainly can reimplement the driver for your MC, though I personally would not want to waste the time on something like this when I can assemble a solution from existing components. Database protocols are typically chatty, synchronous, and sensitive to network quality, and I wouldn't want to waste my MC cycles on that when I can make middleware do that asynchronously. - mustaccio
Simply "reverse ssh port forwarding"? That can be done, I think, with a single ssh command at one (or both) end of the connection. MySQL, by default, needs the client to connect on port 3306 to the server. - rick-james

How do I connect my Android Application to a MySQL database stored in a server?

Background on the MySQL database: it was created from a Wordpress website. As far as I know, it can only be accessed through PuTTy with the ff credentials given to me by my client who I’m making the app for:
hostname
port
my username to get into server
my password to
get into server
mysql username
mysql password
It says from multiple sites that this is the PHP syntax to connect Android to MySQL
// Connecting to mysql database
$con = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die(mysql_error());
It does not work and when checked for the connection error, it shows the error “Connection timed out.” when I put credentials needed (hostname, mysql
username and password). I’m assuming it’s because I need to get into the server first (with credentials #3 and #4).
Is there a workaround to this?
EDIT:
This is only based on the assumption that I am supposed to create a PHP file (that I will place inside a Jave file in Android Studio) to connect to their database. Are there other ways to connect to a private server?
Welcome Ateshi!
It sounds like you want an android app to directly access the mysql database that holds the content of a wordpress website.
The MySQL database server is most likely not publicly available on the internet for good reasons (security), as per this answer
You have posted some PHP code. PHP usually runs on the server alongside mysql, it not usually run on android.
Here is how you usually set up something like this:
Your android app makes a web request to http://yourexampleserver.com/example.php
Inside that example.php which is on the server, you have the PHP code that then does:
connects to mysql (with local credentials)
perhaps writes to the database
perhaps queries the database
formats the results into a useful format like JSON
The results are returned to java on your android which then usually shows them in the UI etc
This whole process is usually described as building a "webservice" for the app to use.
If however, you want the database contents to be stored offline and locally on android, then you probably need to connect to the server manually, export the database and download it, and then include it in your android project.

ODBC Call Failed between Access 2010 and Advantage database server Over a network

First and Foremost, I know zip, zilch, nada, about VBA, access, and Advantage database Server.
I have a PC in one location that can connect and update with an Access 2010 file where every drive is mapped, e.g. \file\whatever
The advantage streamlinesql odbc dsn's were setup as such \file\whatever foxpro
Now, the PC has been moved to a new location (the company moved) and there is a vpn connection between the two locations (the data server is still located in the old location and cannot be moved), and so the new map would look like this: \xxx.xxx.xxx.xxx\file\whatever
However, Access cannot connect so that it can run its process and update the files it needs to.
I do not know the actual code to place here to help with fixing this, so answering this question with more is fine with me.
I can say that the vpn is built with sonic wall.
The first thing I would try is to connect with ARC32 (The ADS query tool), since you can then rule out ODBC and Access as the problem.
ADS has three connection types:
local
remote
internet
When you directly connect to an Advantage Database Server via TCP/IP, you want the remote connection type.
The connection type can usually be set via the ads.ini file, which also must contain the IP address and port for the ADS server:
[SETTINGS]
ADS_SERVER_TYPE=2
[MYDATABASE]
LAN_IP=10.20.1.20
LAN_PORT=6262
For more info about ADS.ini see the official documentation:
http://devzone.advantagedatabase.com/dz/webhelp/Advantage12/master_ads_ini_file_support.htm
When you try connection over ODBC maybe a complete reference of the connection options would be useful, I have written them down here:
https://stackoverflow.com/a/33544131/426242

How to open a new connection in mysql-workbench from the command line

I have used mysql-workbench on both Windows and Linux (Ubuntu) for a while now, and I find it's interface very comfortable, so when I needed a good GUI MySQL client to integrate with my code this was the obvious choice.
My MySQL connections parameters are saved in my server (IP, user, password) and I want to use these paremeters to open a mysql-workbench query window.
I read the command line arguments help (I use version 6.0) and it seems I can open a specific connection by it's name, but I want the code to be independent of my saved connections as I trust the connection info from my server more than one saved in mysql-workbench.
Is there an option to connect to an "anonymous" connection, or to create/manipulate connections from the shell (in either Windows or Linux)?
No, there's no such feature. Always use the connection name. If you want you can create a feature request at http://bugs.mysql.com to get attention for your wish.

Classic ASP Remote SQL Connection String

I have a dilemma which is completely and utterly baffling me...
We have a Classic ASP site which has been running for about a year, its powered via a local Win2008 SQL database (The SQL Express engine is on the same server as IIS). This is the connection string we currently use
Provider=SQLNCLI10;Server=SERVERNAME\SQLEXPRESS;Database=dbname;user id=username;password=password;
We now have a need to move the database to a dedicated DB server, and connect to it remotely - We restored the DB on the server, and checked everything looked ok (All data is present in all tables)
So we changed the server name to the IP address and was unable to get it to connect, in the end the only way we could get it to connect was using this connection string.
driver={SQL Server Native Client 10.0};server=IPADDRESS\SQLEXPRESS,1433;uid=user;pwd=password;database=dbname;
HOWEVER... Now it's randomly missing product names and SKU's and prices in the front and back end, even though the data is present in the DB AND it is REALLY slow to display the webpages? If I use the same DB locally with the previous connection string its fine and all data is appearing?
I know this DB server is fine as it powers other ASP.NET sites with via a remote connection and they are very fast to connect?
Any hints... or help on why this new connection string is causing problems with reading data from the DB???
To update the native client on the web server to the most recent public version, go here:
http://support.microsoft.com/hotfix/KBHotfix.aspx?kbnum=2567714
Check the box for "2008R2_SP1_SNAC_CU2_2567714_10_50_2772_x86" if your web server is an X86 machine, and "2008R2_SP1_SNAC_CU2_2567714_10_50_2772_x64" if it is 64-bit. Enter your e-mail address, fill in the captcha, hit "Request hotfix" and the download link will be e-mailed to you. Download it to the web server, run the installer (using the password sent to you in the e-mail) and restart the web server. Now try your original connection string again.
EDIT
Adding some other sample connection strings that I have used in the past (I've been a classic ASP guy since the 90s, founding and writing 95% of the content on aspfaq.com, including this article on connection strings). As requested in a comment to the original question.
Note that "srv" could be IP address, or localhost, or servername, or . and it could be followed by \INSTANCE_NAME (e.g. \SQLEXPRESS). I would try them in this order, and pay attention to the parameter names as well as the values - you seem to mixing modern parameter names (e.g. Provider) with less modern ones (e.g. Database).
Provider=SQLNCLI10;Data Source=srv;Initial Catalog=db;User ID=user;Password=pwd;
Provider=SQLOLEDB.1;Data Source=srv;Initial Catalog=db;User ID=user;Password=pwd;
Provider=SQLOLEDB;Data Source=srv;Initial Catalog=db;User ID=user;Password=pwd;
Driver={SQL Server};Server=srv;Database=db;UID=user;PWD=pwd;
Sometimes if you are having issues with Named Pipes or Shared Memory it can help to enforce TCP/IP by adding the following parameter:
NETWORK=DBMSSOCN;
You can get a lot more information over at Carl Prothman's site or ConnectionStrings.com. They no longer cater to classic ASP specifically, for obvious reasons, but you can still glean a lot of information from the samples they provide for other languages.