connection of sql server in c-sharp

Sep 25 2010 3:12 AM

hello every :
i am writing a code to establish connection of sql server 2000 in c-sharp .
private
void button_connected_with_database_Click(object sender, EventArgs e)
{
SqlConnection conn;
string string_connection=null;
string_connection = "Data Source=. ; Initial Catalog=Northwind; User ID=sa;Password=sumaira";
conn = new SqlConnection(string_connection);
try
{
conn.Open();
MessageBox.Show(" Connection Open ! ");
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
}
but this code is not working . the message box show " can not open connection ".
 

Answers (1)