connecting to sql server 2000 from c#2008
dear friends,
i have sqlserver2000 installed in my desktop and vs 2008 in my laptop, now i am trying to connect local sqlserver2005 express on laptop i am able to connect, but if i am trying to connect to sqlserver2000 on my desktop i am not able to connect to my database.
hear is the sample code:-
csharp
using System;
using System.Data;
using System.Data.SqlClient;
namespace Chapter09
{
class SqlServerProvider
{
static void Main(string[] args)
{
// set up connection string
string connString = @"server = NSN\NSN;integrated security = true;database = northwind";
// string connString = @"server =nsn;integrated security = true;database = northwind";
// set up query string
string sql = @"select * from employees ";
// declare connection and data reader variables
SqlConnection conn = null;
SqlDataReader reader = null;
try
{
// open connection
conn = new SqlConnection(connString);
conn.Open();
// execute the query
SqlCommand cmd = new SqlCommand(sql, conn);
reader = cmd.ExecuteReader();
// display output header
Console.WriteLine( "This program demonstrates the use of " + "the SQL Server Data Provider." );
Console.WriteLine( "Querying database {0} with query {1}\n" , conn.Database , cmd.CommandText );
Console.WriteLine("First Name\tLast Name\n");
// process the result set
Console.WriteLine("|___________|___________|");
while (reader.Read())
{
Console.WriteLine("|{0} | {1}|", reader["FirstName"].ToString().PadLeft(10), reader[1].ToString().PadLeft(10));
Console.WriteLine("|___________|___________|");
}
}
catch (Exception e)
{
Console.WriteLine("error" + e);
Console.WriteLine("Databse Not Found..." );
}
finally
{
// close connection
Console.WriteLine("closing reder and connections");
Console.ReadLine();
reader.Close();
conn.Close();
}
}
}
}
Mod Edit: Please use code tags when posting your code. Code tags are used like so =>

Thanks
PsychoCoder