[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 514
  • Last Modified:

MonthCalendar and textbox

Hello all,

I do I get a monthcalendar control to populate a textbox, and when the textbox is populated make the textbox search the database for all the information on that date ?

I thank you in advance
0
abennett10
Asked:
abennett10
  • 2
  • 2
  • 2
1 Solution
 
razorback041Commented:
on calendar.change event
textbox.text = calendar selected value

on textbox text changed event
 searchDB(textbox.text) <~ call your function here

this will search everytime they change the date, so if you accidently choose the wrong date..it will still search

0
 
abennett10Author Commented:
I don't see a selectedvalue attribute
0
 
abennett10Author Commented:
It was actually textbox.text = calendar.SelectionStart.ToShortDateString
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
razorback041Commented:
I wasn't sure if you were using a custom control for the calendar, hence the non  specific methods....I was just trying to steer you towards the route of automating the procedure.  Good luck.
0
 
maralansCommented:
What kind of DB and how are you displaying the returned data?
0
 
maralansCommented:
1.  Add a datagrid(dg) to your form.
2.  Add a button(btnSearch) to your form.
3.  Connect to your database and return a dataset.
4.  Bind the datagrid to the dataset.
5.  When you select a date on the calendar, the date will appear in the textbox.
6.  Hit the btnSearch and it will search your dataset and return records that match the value in the textbox and appear in     the datagrid.
7.  DOB in this example is Date Of Birth.

Imports System
Imports System.Data
Imports System.Data.Oledb

Public Class Form1
    Dim cs As String = "provider=microsoft.jet.oledb.4.0;data source =c:\members.mdb "
    Dim cn As New OleDb.OleDbConnection(cs)
    Dim da As New OleDb.OleDbDataAdapter(" Select * From CreditApplication", cn)
    Dim ds As New DataSet


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        da.Fill(ds)

        dg.DataSource = ds.Tables(0)
    End Sub

    Private Sub Calendar_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles Calendar.DateChanged
        Dim selectDate As Date = Me.Calendar.SelectionStart
        textbox.Text = selectDate
    End Sub

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Dim DOB As String = "05/01/2006"

        Dim dv As DataView = ds.Tables(0).DefaultView

        dv.RowFilter = "DOB LIKE '%" + textbox.Text + "%' "

    End Sub

   
End Class

should work for both access and mySql
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now