Hi,
I'm executing a SQL String that gets the Top 1 value from a column. This value is of type int. I would like to save this value to a variable to be displayed later in a prompt (DisplayValue). Here's my code:
int DisplayValue;
string strSQL = "SELECT TOP 1 VALUE FROM LIST";
SqlCommand cmd = new SqlCommand(strSQL, conn);
//Create/Populate the DataReader
SqlDataReader dr;
dr = cmd.ExecuteReader();
I'm not sure how to pass dr to "DisplayValue". I have tried using:
DisplayValue = dr.GetValue();
But have not been successful. Any advice will be greatly appreciated! Thanks!!!
I'm executing a SQL String that gets the Top 1 value from a column. This value is of type int. I would like to save this value to a variable to be displayed later in a prompt (DisplayValue). Here's my code:
int DisplayValue;
string strSQL = "SELECT TOP 1 VALUE FROM LIST";
SqlCommand cmd = new SqlCommand(strSQL, conn);
//Create/Populate the DataReader
SqlDataReader dr;
dr = cmd.ExecuteReader();
I'm not sure how to pass dr to "DisplayValue". I have tried using:
DisplayValue = dr.GetValue();
But have not been successful. Any advice will be greatly appreciated! Thanks!!!