sql connection with stored procedure using windows authentication
SqlConnection baglanti = new SqlConnection("Data Source=.\SQLEXPRESS; Initial Catalog=YOUR_TABLE_NAME; Integrated Security=SSPI; Persist Security Info=false; Trusted_Connection=Yes");
baglanti.Open();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
DataSet ds= new DataSet();
try
{
cmd = new SqlCommand("YOUR_PRODECURE", baglanti);
cmd.CommandType = CommandType.StoredProcedure;
da.SelectCommand = cmd;
da.Fill(dt);
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
catch (Exception x)
{
MessageBox.Show(x.GetBaseException().ToString(), "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
cmd.Dispose();
baglanti.Close();
}