sherbug1015
asked on
Returning a single date from a database
I need to return a date from a database. I can't seem to get it to return. this is what I have so far. Can anyone help. thanks
SqlConnection sqlConnection1 = new SqlConnection("MyConnectSt ring");
SqlCommand cmd = new SqlCommand();
DateTime returnValue;
cmd.CommandText = "SELECT PollOpenTo from Polls.Dates";
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
returnValue = cmd.ExecuteScalar();
sqlConnection1.Close();
SqlConnection sqlConnection1 = new SqlConnection("MyConnectSt
SqlCommand cmd = new SqlCommand();
DateTime returnValue;
cmd.CommandText = "SELECT PollOpenTo from Polls.Dates";
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
returnValue = cmd.ExecuteScalar();
sqlConnection1.Close();
what do you get in your returnValue variable? Any errors?
ASKER
i get an error that it can't convert ExecuteScalar to non-delegate type System.Datetime. Did you intend to invoke a method
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.