Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date field displays as DateTime
Message
From
11/12/2009 16:56:26
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Date field displays as DateTime
Miscellaneous
Thread ID:
01438717
Message ID:
01438717
Views:
101
I put a DropDownList on a form. Included in the Page_Load method is the following code
        If Not IsPostBack Then
                    .
                    .

            Dim strConn As String = CType(Me.Master, MasterPage).connectString
            Dim objConn As New MySqlConnection(strConn)
            Dim objDS As New DataSet

            Dim strSql As String
            strSql = "SELECT DISTINCT savedate FROM kpi_mrpactionsvalue " & _
                     "  ORDER BY savedate DESC LIMIT 10"

            Dim daDates As New MySqlDataAdapter(strSql, objConn)
            daDates.Fill(objDS, "dtDates")

            For Each rowDate In objDS.Tables("dtDates").Rows
                ddlDates.Items.Add(rowDate("savedate"))
            Next

                    .
                    .
This works the way I expect (the DDL is populated with the correct 10 dates)

The next step is to try and bind the DDL to an SqlDataSource. I commented out the Page_Load code and configured the DataSource as follows
< asp:DropDownList ID="ddlDates" runat="server" Height="20px" Width="107px" 
       DataSourceID="mysqldatasource" DataTextField="savedate" 
       DataValueField="savedate" >
 < /asp:DropDownLis t >

< asp:SqlDataSource ID="mysqldatasource" runat="server" 
       ConnectionString="< %$ ConnectionStrings:ConnectionString % >" 
       ProviderName="< %$ ConnectionStrings:ConnectionString.ProviderName % >" 
       SelectCommand="select distinct savedate from kpi_mrpactionsvalue order by savedate desc limit 10" >
< /asp:SqlDataSource >
This also produces a DDL with the correct 10 dates. However, the values show up as DateTime. The Time portion is 12:00:00 AM for all the rows in the DDL. The backend is MySql and I've verified that the field in question is actually a Date rather than a DateTime (I did a visual verification and I also put the SelectCommand as a parameter into a VFP SQLEXEC command with the resulting cursor having Date values)

Any explanation and code corrections gratefully appreciated.............Rich
Next
Reply
Map
View

Click here to load this message in the networking platform