using System.Data.SqlClient;
private void button1_Click(object sender, EventArgs e)
{
string connectionString = "Data Source=SERVERNAME;Initial Catalog=BASENAME;Persist Security Info=True;User ID=USERNAME;Password=PASSWORD";
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
string cmdText = "select * from TBL1";
SqlCommand cmd = new SqlCommand(cmdText, conn);
SqlDataReader rdr = cmd.ExecuteReader();
DataTable tbl = new DataTable();
tbl.Load(rdr);
dataGridView1.DataSource = tbl;
conn.Close();
}