Adding DateTimePicker to DatagridView
Hello Everyone,
I am using the code below to bind data to datagridview. The problem is I don't want to bind the DateBooked, ArrivalDate,& DepartureDate to a DataGridView Text Box. I wana bind them to a dateTimePicker so please I need someone to send me the source code in a simplest way because iam still beginner, so I can understand it well...Your earliest reply will be highly appreciate it.
Private Sub FillDataGridView()
Dim da As New OleDbDataAdapter
Dim ds As DataSet
Try
ds = New DataSet
connDB.closeConn()
connDB.openConn()
da.SelectCommand = New OleDbCommand
da.SelectCommand.Connection = connDB.getConn
da.SelectCommand.CommandType = CommandType.Text
da.SelectCommand.CommandText = "Select Rooms.RoomNumber as [Room Number], RoomType.Description as [Room Type], " & _
"RoomType.ratePerNight As [Price/Night], Booking.DateBooked As[Booked In], Booking.ArrivalDate as [Check In], " & _
"Booking.DepartureDate As [Check Out], Booking.Status " & _
"From Booking, Customers, Rooms, RoomType " & _
"Where Customers.CustomerID = Booking.CustomerID " & _
"and Booking.RoomNumber = Rooms.RoomNumber " & _
"and Rooms.idType = RoomType.idType " & _
"and Customers.Name = '" & cmbBoxSrch.Text & "'"
da.Fill(ds, "Customers")
da.Fill(ds, "Rooms")
da.Fill(ds, "Booking")
da.Fill(ds, "RoomType")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "Customers"
DataGridView1.DataSource = ds
DataGridView1.DataMember = "Rooms"
DataGridView1.DataSource = ds
DataGridView1.DataMember = "Booking"
DataGridView1.DataSource = ds
DataGridView1.DataMember = "RoomType"
Catch ex As OleDb.OleDbException
MessageBox.Show(ex.Message)
End Try
connDB.closeConn()
End Sub
|