By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,649 Members | 2,154 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,649 IT Pros & Developers. It's quick & easy.

SQL Connecting Problems

P: n/a
A simple app I quickly wrote to try getting info from a database. Here
is the first part of its code. The rest of the code is irellevant.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Threading;

namespace TestSQL
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
// Make SQL connection
Console.WriteLine("Connecting to SQL database
server...");
SqlConnection conn = new SqlConnection("CONNECT TIMEOUT=2;
SERVER=localhost; DATABASE=doomconnector; USER ID=codeimp;
PASSWORD=#########; ENCRYPT=false; POOLING=false;");
try { conn.Open(); }
catch(SqlException e)
{
Console.WriteLine("ERROR " + e.Number + ":
" + e.Message);
}
...
The output of this code:[quote:5608abe1e3]Connecting to SQL database
server...
ERROR 11: General network error. Check your network
documentation.[/quote:5608abe1e3]
Im using Windows 2000 Pro (completely up-to-date according to
www.windowsupdate.com).

I have installed the MySQL windows server on localhost and changed the
passwords as well as creating that "codeimp" account with all
privileges. I can login to that using the mysql console application
and perform operations without problems.

I have installed MDAC 2.8, no problems.

Using the Data Sources (ODBC) from the control panel, I am unable to
add a User DSN with the same settings (gives me the same error). I
have tried many different settings down to the most stupid things
like trying 127.0.0.1 instead of 'localhost', but nothing got any
better.

My network is fine and its on localhost so that shouldnt matter.
TCP/IP protocols installed and work fine as you can see, because I
can make this post.

I read some KB articles that talk about errors with this description
but they did not apply to my problem here.

What could this be? What should I do now? Help me please :)

Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"CodeImp" <gh*******@hotmail-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
A simple app I quickly wrote to try getting info from a database. Here
is the first part of its code. The rest of the code is irellevant.
using System;
using System.Data;
using System.Data.SqlClient; .. . . I have installed the MySQL windows server on localhost and changed the
passwords as well as creating that "codeimp" account with all


.. . .

System.Data.SqlClient is the provider for Microsoft Sql Server.

David
Nov 16 '05 #2

P: n/a
SqlClient is for Microsoft Sql Server Server only.

To connect to MySQL take a look at the following information
http://www.devhood.com/tutorials/tut...utorial_id=576
"CodeImp" <gh*******@hotmail-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
A simple app I quickly wrote to try getting info from a database. Here
is the first part of its code. The rest of the code is irellevant.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Threading;

namespace TestSQL
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
// Make SQL connection
Console.WriteLine("Connecting to SQL database
server...");
SqlConnection conn = new SqlConnection("CONNECT TIMEOUT=2;
SERVER=localhost; DATABASE=doomconnector; USER ID=codeimp;
PASSWORD=#########; ENCRYPT=false; POOLING=false;");
try { conn.Open(); }
catch(SqlException e)
{
Console.WriteLine("ERROR " + e.Number + ":
" + e.Message);
}
...
The output of this code:[quote:5608abe1e3]Connecting to SQL database
server...
ERROR 11: General network error. Check your network
documentation.[/quote:5608abe1e3]
Im using Windows 2000 Pro (completely up-to-date according to
www.windowsupdate.com).

I have installed the MySQL windows server on localhost and changed the
passwords as well as creating that "codeimp" account with all
privileges. I can login to that using the mysql console application
and perform operations without problems.

I have installed MDAC 2.8, no problems.

Using the Data Sources (ODBC) from the control panel, I am unable to
add a User DSN with the same settings (gives me the same error). I
have tried many different settings down to the most stupid things
like trying 127.0.0.1 instead of 'localhost', but nothing got any
better.

My network is fine and its on localhost so that shouldnt matter.
TCP/IP protocols installed and work fine as you can see, because I
can make this post.

I read some KB articles that talk about errors with this description
but they did not apply to my problem here.

What could this be? What should I do now? Help me please :)

Nov 16 '05 #3

P: n/a
Ah thanks,.. so the server you use matters. I thought SQL is a query
language that many servers support in the same way. Bah, I guess
doing it through ODBC makes it a windows-only application, no?

Nov 16 '05 #4

P: n/a
"CodeImp" <gh*******@hotmail-dot-com.no-spam.invalid> wrote in message
news:41********@Usenet.com...
I thought SQL is a query language that many servers support in the same way.

It certainly is and, once you've made a connection to the particular
SQL-compliant RDBMS in question, you should be able to query it with
"standard" SQL. But you need to be able to make that connection in the first
place!
Bah, I guess doing it through ODBC makes it a windows-only application,

no?

No need to use ODBC any more - lots of RDBMS (including mySQL) provide
native .NET providers these days and, for those which don't, there is a very
good chance that an OleDb provider will exist.

This page will be of some help: http://www.connectionstrings.com/ It
describes where you can obtain native .NET providers for mySQL, including a
free one, and also documents how to construct your connection strings.
Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.