Wasim Sayyed King
Member
- Joined
- Mar 24, 2012
- Messages
- 7
- Location
- Mumbai, Maharashtra, India, India
- Programming Experience
- 1-3
how to select records of today from access table???????????????? for creating crystal report for printing bills of today
Dim connection As New OleDbConnection("Provider=Microsoft.ACE.OLED B.12.0;Data Source=D:\My Project\My Project\Stone Crusher\myproject.accdb") Dim adapter As New OleDbDataAdapter("SELECT * from Transaction_table WHERE vehicle_number = @vehicle_number AND Date_transaction = @Date_transaction", connection) With adapter.SelectCommand.Parameters .AddWithValue("@vehicle_number", vehicleNumber) 'vehicleNumber is a String variable containing the vehicle number. .AddWithValue("@Date_transaction", Date.Today) End With Dim table As New DataTable Try adapter.Fill(table) DataGridView1.DataSource = table Catch ex As Exception 'Error handling code goes here. End TryThat assumes the the Date_transaction column contains just dates and no times. If it contains times as well then you'll need to specify a range, e.g.
Dim connection As New OleDbConnection("Provider=Microsoft.ACE.OLED B.12.0;Data Source=D:\My Project\My Project\Stone Crusher\myproject.accdb") Dim adapter As New OleDbDataAdapter("SELECT * from Transaction_table WHERE vehicle_number = @vehicle_number AND Date_transaction >= @Date_transaction1 AND Date_transaction < @Date_transaction2", connection) With adapter.SelectCommand.Parameters .AddWithValue("@vehicle_number", vehicleNumber) 'vehicleNumber is a String variable containing the vehicle number. .AddWithValue("@Date_transaction1", Date.Today) .AddWithValue("@Date_transaction2", Date.Today.AddDays(1)) End With Dim table As New DataTable Try adapter.Fill(table) DataGridView1.DataSource = table Catch ex As Exception 'Error handling code goes here. End Try