Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Posted May 25, 2011, 8:36 PM EDT
using (SqlConnection con = new SqlConnection())
{
string constr = @"Data Source=MURALIDHARAND\SQL2008R2;Initial Catalog=DestinationDB;Integrated Security=True;MultipleActiveResultSets=true";
con.ConnectionString = constr;
con.Open();
SqlCommand cmd1 = con.CreateCommand();
SqlCommand cmd2 = con.CreateCommand();
cmd1.CommandText = " select * from division";
cmd1.CommandType = CommandType.Text;
SqlDataReader reader1 = cmd1.ExecuteReader();
if (reader1.HasRows)
{
reader1.Read();
cmd2.CommandText = " select * from subdivision";
cmd2.CommandType = CommandType.Text;
SqlDataReader reader2 = cmd2.ExecuteReader();
if (reader2.HasRows)
{
MessageBox.Show("Success");
}
}
}
Hope this helps you.
MarcusRank #1,197 · 1.5K reputationPosted May 25, 2011, 8:40 PM EDT
vikram thakur29 reputationPosted Aug 4, 2011, 3:45 AM EDT
shams khan10 reputationPosted Aug 5, 2011, 3:22 AM EDT