1

THIS IS MY CODE.... bUt i am not getting the data between the given dates IN THE DATAGRID VIEW
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim ConnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\Users\Anand\Documents\db.accdb"

    Dim dfrom As DateTime = DateTimePicker2.Value
    Dim dto As DateTime = DateTimePicker1.Value



    Dim SQLString As String = "SELECT * FROM cc WHERE Produced Between '" & DateTimePicker2.Value.Date & "' AND '" & DateTimePicker1.Value.Date & "'"

    Dim OleDBConn1 As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(ConnString)
    Dim DataSet1 As New DataSet()
    Dim OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter(SQLString, OleDBConn1)
    OleDBConn1.Open()
    OleDbDataAdapter1.Fill(DataSet1, "cc")
    DataGridView1.DataSource = DataSet1.Tables("cc")

    Dim total As Integer
    For Each row As DataGridViewRow In DataGridView1.Rows
        total += row.Cells("Total").Value
    Next
    TextBox2.Text = total

    Dim trejects As Integer
    For Each row As DataGridViewRow In DataGridView1.Rows
        trejects += row.Cells("TRejects").Value
    Next
    TextBox1.Text = trejects


End Sub

Edited by pritaeas: Closed.

Votes + Comments
The first thing you need to do is to make sure that your data field is specified ad date and then your code should look like. e.g select* from cc where date= datetimer1 between datetimer2
3
Contributors
2
Replies
17
Views
3 Years
Discussion Span
Last Post by pritaeas
0

Your first problem is, this is the wrong forum. You want the VB.NET forum.

Edited by tinstaafl