However, you can connect to an sqlserver using an OdbcConnection instead of an SqlConnection.
You simply create the connetion like this :
OdbcConnection connection = new OdbcCOnnection("DSN=the_na
Main Topics
Browse All TopicsHi,
hw to connect sqlserver using DSN in C# windows application?.
Can anyone help me out in this regard?
thnkx
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
public void InsertRow()
{
myConnection = DSN=Northwind;
OdbcConnection myConn = new OdbcConnection(myConnectio
string myInsertQuery = "INSERT INTO Customers (CustomerID, CompanyName) Values('NWIND', 'Northwind Traders')";
OdbcCommand myOdbcCommand = new OdbcCommand(myInsertQuery)
myOdbcCommand.Connection = myConn;
myConn.Open();
myOdbcCommand.ExecuteNonQu
myOdbcCommand.Connection.C
}
public void ReadMyData(string myConnString) {
string mySelectQuery = "SELECT OrderID, CustomerID FROM Orders";
OdbcConnection myConnection = new OdbcConnection(myConnStrin
OdbcCommand myCommand = new OdbcCommand(mySelectQuery,
myConnection.Open();
OdbcDataReader myReader;
myReader = myCommand.ExecuteReader();
// Always call Read before accessing data.
while (myReader.Read()) {
Console.WriteLine(myReader
}
// always call Close when done reading.
myReader.Close();
// Close the connection when done with it.
myConnection.Close();
}
can u pls send me the url if u hv???? u told that ".NET Framework reference documentation"
"From the .NET Framework reference documentation :
Note The .NET Framework Data Provider for SQL Server uses its own protocol to communicate with SQL Server. Therefore, it does not support the use of an ODBC data source name (DSN) when connecting to SQL Server because it does not add an ODBC layer."
If you have the .NET SDK installed then you alreday have this documentation on your computer.
To open the documentation check your start menu (assuming you are using a version of windows that has one and that you have .NET 1.1) :
Start -> All Programs -> MS .NET SDK 1.1 -> Documentation
If you don't have this, check :
c:\Program Files\Common Files\Microsoft Shared\Help\dexplore.exe
You can run it from a command line like this :
c:\Program Files\Common Files\Microsoft Shared\Help\dexplore.exe /helpcol ms-help://MS.NETFrameworkS
If ytou do not have the .NET SDK installed I seriously recommend that you get it :
http://www.microsoft.com/d
It is quite a big download.
If you can't get all that right now, the whole of the reference documentation is available online :
Here is a link to System.Data.Odbc :
http://msdn.microsoft.com/
Business Accounts
Answer for Membership
by: ozymandiasPosted on 2003-12-16 at 14:00:53ID: 9952598
From the .NET Framework reference documentation :
Note The .NET Framework Data Provider for SQL Server uses its own protocol to communicate with SQL Server. Therefore, it does not support the use of an ODBC data source name (DSN) when connecting to SQL Server because it does not add an ODBC layer.