SQL Connecting Problems

  • Thread starter Thread starter CodeImp
  • Start date Start date
C

CodeImp

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 :)
 
CodeImp said:
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
 
SqlClient is for Microsoft Sql Server Server only.

To connect to MySQL take a look at the following information
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=576


CodeImp said:
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 :)
 
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?
 
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.
 
Back
Top