Wednesday, March 21, 2012

Datetime query issue with C# stored procedure

Ok, i am using the convert function to get the date format from my datetime column. My problem is when C# try's to pull the column name the column name is not sent in the query. When I run the query in the query analyzer the column name is blank in the result window. How can I get the date from the record with out losing the name of my column in the query. My data binding needs the name of the column to bind the data to the drop down list control. Here is the statement:

SQL statement
SELECT DISTINCT convert(datetime, eventDT, 110) FROM tblRecognition

C# code
ddlDateTo.DataSource = _uiCode.Fill.Date();
ddlDateTo.DataTextField = "eventDT";
ddlDateTo.DataBind();

Thank you,assign a column alias in your SELECT

convert(datetime, eventDT, 110) as displaydate

ddlDateTo.DataTextField = "displaydate";|||well that was simple lol. thank you, i don't know why that didn't accur to me.

No comments:

Post a Comment