Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Date field displays as DateTime
Message
De
21/12/2009 20:49:08
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
 
À
21/12/2009 18:58:05
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01438717
Message ID:
01440108
Vues:
38
Edit, sorry, misread your question. Looks like Charles got you where you wanted to be.

>Thanks Mike.


>I've found some references to how to do this with ASP properties. Since I'm doing everything in the VB code-behind, do you have any suggestions/samples for how to apply the formatting to a particular column?
>
>
>>.NET doesn't have a Date type... only a DateTime. You will need to handle this by formatting your front-end display code.
>>
>>>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
Very fitting: http://xkcd.com/386/
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform