Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2007

    Unanswered: 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";
    Thank you,

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    assign a column alias in your SELECT

    convert(datetime, eventDT, 110) as displaydate

    ddlDateTo.DataTextField = "displaydate"; | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Aug 2007
    well that was simple lol. thank you, i don't know why that didn't accur to me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts