Delphi and mysql - Unable to connent to server..maybe custom connection reqd - mysql

I am coding an application for my company wherein i want to parse the results of a mysql query and display them in my application but i am facing a problem conecting to the database.
the ip address of the server is : 172.30.192.20
and before i can ping it i have to add route on my pc something like this
route add 172.30.192.0 mask 255.255.255.0 172.30.192.56
where 172.30.192.56 is the gateway
Now whenever i try to connect 172.30.192.20 which is where the sql server is running my appplication instead connects to 172.30.192.56
i am coding the application in delphi and have used TmySQL
After this didnt workout i tried an application called SQLwave. I just entered the server ip address and was able to connect to the database without any problems. it seems sqlwave uses mydac which is why even i tried using it but using the default connection options and setting i was still not able to connect. it seems sqlwave uses a custom connection using mydac
i just want to know whats going wrong with my connection

I tend to use the ADO Components. Here's a small (simple) example you may want to try...
Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=myDataBase; User=myUsername;Password=myPassword;Option=3;
Above is a Connection String, using the MySQL ODBC 5.1 driver (available on the MySQL website if you don't already have it). Modify this to reflect your server address, database name, username and password. Paste this into the "ConnectionString" property of a TADOQuery.
Set this ADOQuery object's SQL text to something like
SELECT * FROM mytable
Where "mytable" is the name of an existing table in your database.
Now change the ADOQuery object's Active property to True.... see what happens.
As Mason suggested, you may simply be experiencing a connectivity issue, still you never know, my method may come in handy!
Good luck!

Related

Can i use Cakephp 2 with mysql without using PDO?

I'm trying to host a cakephp2 application on an old managed server that has pdo_mysql disabled. Politics dictates that I'm unable to rectify this problem, so I'm looking for connection alternatives.
cakephp is producing the following error:
"A Database connection using "Mysql" was missing or unable to connect.
The database server returned this error: Selected driver is not enabled"
Is there a way to connect to the database using the older mysql database extension?
There's no easy way to do it.
If you want to, you could write your own DboSource class, you could reuse the the existing one and use the old-deprecated mysql database extension. (Or if you're lucky you could find one on the internet, but i doubt it)
Then you'll only need to change the DboSource in your settings to use your own class
Hope this helps

Connect ColdFusion to SQL Server database instance

I am trying to connect to a SQL server (2008) database instance in ColdFusion 9 but there is no where to put an instance name in the CF administrator. I can get in with .net using a connection string like so:
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;
Password=myPassword;
There is a place to enter a connection string in ColdFusion but I don't seem to be able to connect to the right instance (it seems to connect to the default instance). Is there a way to connect ColdFusion to a SQL Server database instance in the administrator?
If you are NOT using ColdFusion's sandbox security then you can specify the instance name in the server field of the datasource definition in the ColdFusion administrator. As you mentioned, you would just specify myServerName\myInstanceName. But...
If you are using ColdFusion's sandbox security then that will not work. I had this same issue when I upgraded to ColdFusion 9 and never did find a resolution. I entered a bug at Adobe for it: ColdFusion 9.0.1 Bug 84928 It has since been closed as "Deferred" with the reason "Not Enough Time".
I found that the connection issue arose when using ColdFusion's sandbox security. Disable it and the datasource will work with the instance name specified per above. Enable it and that same connection will fail.
In order to get around the bug you need to specify the database server only (without the instance name) in the server name field and specify the assigned port number for the named instance in the port number field. See the bug for full details.
Simply enter the Server with a \ and the name of the instance

Cannot connect Delphi App to mySQL database

I have installed a local server Xampp, which is running mySQL database in Windows. I created a Database on it with one table. The thing is I cannot get a connection to the database when I use the dbExpress TSQLConnection component. When I set the properties as follows:
ConnectionName = MYSQLConnection
Driver = MySQL
Database = databaseName
HostName = localhost
password =
UserName = root
When I change the connected property to true, I get the following error:
Borland.Data.TDBXError: DBX Error: Driver could not be properly initialized. Client library may be missing, not installed properly, of the wrong version, or the driver may be missing from the system path
I have tried making a connection to the database using the Data Explorer, but I still get the above error. I do not know what I'm missing or doing wrong.
Im using Delphi-XE2.
with mySQL on the server: MySQL client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $.
I have also tried using an ADO connection, but I do not know how to set the connection string.
I'm still a noob and just want to learn how to make a connection to a mySQL database running on a web server. I cannot afford to buy any components.
Try this!
Did some google Fu - and stumpled upon this link : http://wiltonsoftware.com/posts/view/getting-embarcadero-dbexpress-mysql-working-dbx-error-driver-not-initialized
That seems to fit your needs.
My previous answer was no help .. hope the new one is better.
Old answer:
Make sure you have Data.DBXMySQL in your uses clause.
OK. I'll try a different approach.
Is it working if you setup the connection in the DataExplorer?
If not - then it's not a problem with the uses clause.
(and you obviously have tried that - sry . must be tired :-))
Otherwise a unit could be like this.
unit Unit1;
interface
uses // <-- Uses normally goes right after interface .... (you probably already have one)
Data.DBXMySql;
implementation
end.

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.

How can I connect to Sql Server 2008 remotely using an IP Address?

When I publish my project clients will need to be able to setup the initial configuration, and part of that is the Sql Database Connection. I have an instance of Sql Server 2008 running on my system (MSSQLSERVER2008) as well as SQLEXPRESS2005. I am trying to use the following connection string locally just to see if this works, and I can't get it to work:
ConnectionString = {Data Source=127.0.0.1;Initial Catalog=DCOMProductionsDesktop;Integrated Security=False;User ID=DCOMProductionsDesktopService;Password=;Network Library=dbmssocn}
The error I get is the usual "The target machine actively refused the connection".
*There isn't any firewalls running, and its inside the network anyway
*TCP/IP Protocols are enabled
*Remote Connections are enabled and permitted
So, I'm stumped.
Edit
I changed the connection string's data source to:
DataSource=192.168.0.2\MSSQLSERVER2008 on my WinXP VM (for testing remotely)
Now, this did work. But when I deploy this across the internet, will that same connection string work for clients outside my network using a domain name such as:
DataSource=desktop.dcomproductions.com\MSSQLSERVER2008
Or will I need to do something different?
It will work, as long as "desktop.dcomproductions.com" or whatever, resolves to the proper IP address. So that name should be set up either on the public or private DNS properly.
Also, make sure it resolves to a public/external IP address, unless your client's scripts are going to be within the same network as the SQL server.
Thought I post it as an answer, instead of comments :)
It's been a while sice I used anything but Named Pipes to connect to a sql server instance so this may not be relevent but try changong Data Source to Server.
They may be synonyms, as I said, it's been a while.
Also, even if you are using an IP address, you aren't specificying an instance of sql server to connect to, that may also be causing issues