Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 2nd, 2003, 11:49 AM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add Column to Show Time

Dear Users,

Do anyone know how to add a column to show the time separately from the date. I am retreiving the Long Date(11/2/2003 11:30pm) from an Access Database?

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'GetUser()
        Lost = 0



        If txtStart.Text = "" And txtEnd.Text = "" Or CboItems.Text = "" Then
            MsgBox("Select Date from Above Calendar or Item - Thank you")
        Else

            kStart = txtStart.Text
            kStop = txtEnd.Text
            nItem = CboItems.Text

            Dim conStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\DATA\ACCESS\13FloorEquipment.mdb"
            Dim strSQL As String = "SELECT [ItemName], [StartDate],[EndDate],[NTID] FROM(Requests) "
            strSQL = strSQL & "WHERE (([ItemName]= '" & nItem & "')"
            strSQL = strSQL & "AND (([StartDate])"
            strSQL = strSQL & "BETWEEN #" & kStart & " 12:00:00 AM #"
            strSQL = strSQL & "AND #" & kStop & " 11:59:59 PM #));"
            'MsgBox(strSQL)

            Dim conn As OleDbConnection = New OleDbConnection(conStr)
            conn.Open()
            Dim da As OleDbDataAdapter = New OleDbDataAdapter(strSQL, conn)

            Dim ds As DataSet = New DataSet()
            da.Fill(ds, "Requests")
            Dim dv As DataView = ds.Tables("Requests").DefaultView
            DataGrid1.DataSource = dv
            DataGrid1.ReadOnly = True

            conn.Close()

            'Next
        End If

    End Sub
 
Old December 2nd, 2003, 12:30 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

In a datagrid, you can set up 2 columns, and specify the data format for each. You could have one column only show the date components of the datetime, and the other show the time components of the datetime.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
BindingNavigator show 2 extra when add new row michellebong Visual Basic 2005 Basics 1 March 28th, 2008 10:22 PM
show date/time in a datagrid. mehmetned C# 2005 0 March 23rd, 2007 08:43 AM
show date/time in a datagrid. mehmetned ASP.NET 1.0 and 1.1 Basics 0 March 23rd, 2007 08:38 AM
show just the column names from a MySQL command crmpicco MySQL 5 December 7th, 2006 08:34 AM
SQL not show a certain column ql7500 MySQL 1 January 26th, 2006 08:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.