Reputation: 9064
Can i use the same reader to read results from two result sets?
string checktrigger =
"select name from sys.triggers where name = 'Insertion_in_ITEMS_table' " +
"select object_name(parent_obj)from sysobjects where id =
object_id('Insertion_in_ITEMS_table')";
SqlCommand check_cmd = new SqlCommand(checktrigger, _conn);
SqlDataReader check_reader = check_cmd.ExecuteReader();
string triggername = check_reader.GetString(0);
string tablename = check_reader.GetString(1);
if (triggername.Length != 0)
{
MessageBox.Show(triggername + "CREATED SUCCESSFULLY" + "ON TABLE " + triggername + tablename);
}
this is giving error that index out of bounds should i use array? to return the result set
Upvotes: 0
Views: 1022
Reputation: 32323
User reader.Read()
to get the next record and reader.NextResult()
to switch to the next result in the result set.
while (check_reader.Read())
{
// get rows from the first select
}
// switch to next
check_reader.NextResult();
while (check_reader.Read())
{
// get rows from the second select
}
Upvotes: 3