1
DateTime DT1;

SqlCommand cmd = new SqlCommand("Select DateReceivedProviderInvoice from ProviderInvoices");

now how to assing the result of the query to DateTime variable DT1?!!!!

1 Answer 1

2

You can use SqlCommand.ExecuteScalar Method if you want to get a single value from a column.

SqlCommand.ExecuteScalar: Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.

DT1 = Convert.ToDateTime(cmd.ExecuteScalar());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.