Cannot connect to sql server through Excel or C#


For some reason, I can access my sql server through phpMyAdmin, ssh, and php, but I can’t get a remote connection from my computer. I’ve tried Excel 2003/2007. I’ve tried writing a C# script to connect. I’ve tried connecting from work as well as home. I don’t think it’s a firewall issue. Under my account in the control panel I set it to allow all IPs (%.%.%.%). Is there a simple setting I’m missing? I can’t imagine what I’m doing wrong. Thanks for your help.

Here is my C# code snippet:

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;

namespace ConsoleApplication1
class Program
static void Main(string[] args)
SqlConnection myConnection = new SqlConnection(“user id=ubooks;” +
“password=*******;;” +
“Trusted_Connection=yes;” +
"database=quotecache; " +
“connection timeout=15”);

catch (Exception e)


Have you tried allowing your specific IP address? Allowing full wildcards, even it may work, seems pretty reckless. I’d at least limit it to a specific subnet.



that’s what I tried first. no dice.


If you’re behind a router (DSL/Cable generally) you’ll find that the address you get with “ipconfig” isn’t the same address that a host will see. You might want to make sure you specifically add the external IP address and see if that works.

Once again, check for any firewalls that are preventing your application from contacting the DB. You may want to try the windows admin tool that sort of comes with MySQL, it may be able to help in diagnosing the problem.

Good luck!



I always rely on to find out my external IP address. Especially since my internal network is NATted.



I’ve done all that. I’ve tried setting DMZ on my internal IP address. I’ve tried directly connecting to my cable modem. That didn’t fix it.


I was able to connect with MySQL Administrator so there doesn’t appear to be a fundamental problem. Now that said, I can’t connect to it with other tools but I’m sure it’s because I’m an idiot.



do you mean you tried connecting to my mysql server?


Not yours, but mine at DH.



Ah. Well I just downloaded the MySQL Administrator program you recommended. It connects just fine. I still can’t connect through other programs


I’m trying to do something similar with something else and apparently my tools are fighting with me. But if the Admin tool can connect, it’s encouraging that we should be able to get these things going. I’ll let you know if I have any more luck. (One thing I’m finding is that libmysql.dll needs to be in the path, but it’s not changed my luck yet.)