hendrikbez
Active member
0 down vote favorite
I Have a excel sheet with dates that I want to use datetimepicker with (only date needed). I just want to click on datetimepicker, choose a date and it must show me the info in my data grid view. this is my button code.
I have a txt box that I have tried, but cannot get the date, I have now put a datetimepicker box, but cannot get ii to work.
any help on this.
Hera are my load page info
Here is my button code, I want to display any date that I want.
I Have a excel sheet with dates that I want to use datetimepicker with (only date needed). I just want to click on datetimepicker, choose a date and it must show me the info in my data grid view. this is my button code.
I have a txt box that I have tried, but cannot get the date, I have now put a datetimepicker box, but cannot get ii to work.
any help on this.
Hera are my load page info
VB.NET:
Imports System.Data.OleDb
Public Class Tapes_info
Private dtGlobal As New DataTable
Private Sub Tapes_info_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dtGlobal.Clear()
Using cn As New OleDb.OleDbConnection
Dim Builder As New OleDbConnectionStringBuilder With {.DataSource = IO.Path.Combine(Application.StartupPath, "Backuptapes.xls"), .Provider = "Microsoft.ACE.OLEDB.12.0"}
Builder.Add("Extended Properties", "Excel 12.0; IMEX=1;HDR=No;")
cn.ConnectionString = Builder.ConnectionString
cn.Open()
Using cmd As OleDbCommand = New OleDbCommand With {.Connection = cn}
cmd.CommandText = "SELECT TOP 5130 F1 As Tapes, F2 As Containere, F3 as ContainerRef, F4 as DateOut FROM [Tapese$]"
Dim dr As System.Data.IDataReader = cmd.ExecuteReader
dtGlobal.Load(dr)
LstTape.DisplayMember = "Tapes"
LstTape.DataSource = dtGlobal
txtContainer.DataBindings.Add("Text", dtGlobal, "Containere")
txtContainerRef.DataBindings.Add("Text", dtGlobal, "ContainerRef")
txtDateOut.DataBindings.Add("Text", dtGlobal, "Dateout")
End Using
End Using
End Sub
Here is my button code, I want to display any date that I want.
VB.NET:
Private Sub BtnSearchDateOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSearchDateOut.Click
For i As Integer = 0 To dtGlobal.Rows.Count - 1
If IsDBNull(dtGlobal.Rows(i)("Dateout")) Then
dtGlobal.Rows(i)("Dateout") = ""
End If
Next
Dim query = From item In dtGlobal.AsEnumerable() Where item.Field(Of String)("Dateout").StartsWith(txtSearchDateOut.Text) Select item
If query.Count > 0 Then
Dim newDT As DataTable = query.CopyToDataTable()
MsgBox(newDT.Rows.Count.ToString() & " Date out found.")
Dim frm As New Form()
Dim dgv As New DataGridView()
dgv.DataSource = newDT
dgv.Refresh()
frm.Controls.Add(dgv)
dgv.Dock = DockStyle.Fill
frm.Size = New Size(1400, 700)
frm.Show()
Else
MsgBox("There is no Date for this found.")
End If
Last edited: