With ASP.NET with C#, I am trying display numerous GridViews with different SQL commands. Because the SQL statements are long, I would like to include the variables instead of the actual statements, but I'm not sure exactly how to insert them in the SqlCommand method. Without the variable, the code appears as so
SqlCommand cmd = new SqlCommand("SELECT....; SELECT...." , myConn);
but instead of the actual statement, I'd like to replace the above sql statements with string variables like below...
string sqlVar1 = "SELECT.....";
string sqlVar2 = "SELECT....";
How do I incorporate the variables to the above code? Below does not work.
SqlCommand cmd = new SqlCommand(sqlVar1; sqlVar2, myConn);
Is there a punctuation I'm missing or perhaps additional code is required to recognize that I'm using variables instead of the actual sql statements?