I have a simple SQL query that works in SQL:
select txdate, acct from trans where txdate = '1/31/2017'
I cannot get it to work from C#:
DateTime sDate = dtStart.Value; // date time picker
// connect to server
SqlCommand cmd = new SqlCommand("select txdate from trans where txdate = '@sdate'", cx);
cmd.Parameters.AddWithValue("@sdate", sDate);
var retVal = cmd.ExecuteNonQuery();
var always returns -1 when it returns a set of records in SQLServer. I've been on this for hours. Any help would be greatly appreciated.
This is in a loop that increments days. My objective is to get the results of the first date. I've tried no quotes and it doesn't make a difference.