the code seems to be fine dont know why its not working.
when i execute the same sql directly in database it works fine.

the error is get is oledbexception was unhandled syntax error in from clause. please help me thanks is advance.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim connection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\abrar\My Documents\Database2.mdb")
        Dim sql As String = "SELECT * FROM Transaction where Due_Date > RentedDate + 30 "
        Dim command As New OleDbCommand(sql, connection)

        Try
            connection.Open()
        Catch ex As InvalidOperationException
            MsgBox(ex.Message)
        End Try

        Dim overDueDVDadapter As New OleDbDataAdapter(command)
        Dim overDueDVD As New DataSet


        overDueDVD.Clear()

        overDueDVDadapter.Fill(overDueDVD, "Transaction")



        reportDataGridView.DataSource = overDueDVD.Tables("Transaction").DefaultView

        If connection.State <> ConnectionState.Closed Then
            connection.Close()
        End If

    End Sub

Recommended Answers

All 2 Replies

"Transaction" is a reserved word. Rename your table to "TransactionTable" or something like that.

Thank You very much ,your solution worked.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.