I have wrote this query to get some results, if I want to save the results in an array what I have to do? I want to use the values which are in col1 and col2 in an IF state
Use a SQL DATA READER:
In this example i use a List instead an array.
try
{
SqlCommand comm = new SqlCommand("SELECT CategoryID, CategoryName FROM Categories;",connection);
connection.Open();
SqlDataReader reader = comm.ExecuteReader();
List str = new List();
int i=0;
while (reader.Read())
{
str.Add( reader.GetValue(i).ToString() );
i++;
}
reader.Close();
}
catch (Exception)
{
throw;
}
finally
{
connection.Close();
}