hi! well, i'm just a beginner in visual basic and i have this problem in coding the calendar control. I want to reserve the dates and store it on a database. so when there will be another reservation, i can easily know if the date is already taken. I don't know how to start the code. please help!
1. Is it the code for the calendar control(w/c is stated above) or
2. On how to check if a date selected in the calendar control has already a reservation.
Anyway, what control are you using? is it a month control?, datepicker control? or frankly speaking, the calendar control ->Microsoft Calendar Control ->MSCAL.ocx
If it's calendar control, then here is my idea...this code is a click event of a button, it's up to you on how you will run this code...
Private Sub Command1_Click()
Dim rsCheckReservations As New ADODB.Recordset 'this will our recordset object
Dim holdSelectedDate As String 'this will hold the selected date from the calendar control
'get the values of the calendar control...
holdSelectedDate = Me.Calendar1.Month & "/" & Me.Calendar1.Day & "/" & Me.Calendar1.Year
'.Month -> returns the month number
'.Day -> returns the daynumber
'.Year -> returns the year
If .State = adStateOpen Then .Close
'open the table from the database, this will check if the selected date from the calendar control is free, or reserved.
.Open "SELECT * FROM tblReservations WHERE date='" & holdSelectedDate & "'", cn, adOpenKeyset, adLockOptimistic, adCmdText
'cn -> it's the connection string
'check if there are results.
If .BOF And .EOF = True Then
'if there are no results, then process the reservation....
MsgBox "Date already reserve", vbOKOnly + vbExclamation, Me.Caption
NOTE: I assume that the field for the date column is a string data type or a varchar(in MySQL),
and the string formating is: MM/DD/YYYY,
if you are using MySQL database, its formating for date data type is: YYYY/MM/DD
Just play around a little bit on how you would represent the dates, since that the month, day and year property of the calendar control are separate values...
As the code above, the value of this variable will be the selected month, day and year from the calendar control...
When we open the reservations table (tblReservation), We use the holdSelectedDate as a condition in this SQL statement:
SELECT * FROM tblReservations WHERE date='" & holdSelectedDate & "'"
Here we open the table with a condition, notice the WHERE clause, WHERE clause is used to extract only those records that fulfill a specified condition. This will return only those records that have the same matching date with the holdSelectedDate variable.
This select statement is use to check if the selected date already exists in the table..
Suppose you have five records in your table:
(toggle the code window into plain text for better viewing)
I Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...