Hi,

i have convert my code from sql to mdb but there is problem when it comes to place i highlight in red it doesn't execute the command reader....it end the application when it reaches Do While dr.Readcan any1 tel me whats the wrong with my code.....i'm totally blank !

Public Function Get_PaymentDetails() As Boolean

        Dim myConnection As OleDbConnection
        Dim myCommand As OleDbCommand
        Dim dr As OleDbDataReader
        Dim strSQL As String = ""
        'Dim connStr As String
        'Dim dr As SqlDataReader

        'connStr = "server=(local); database=Bill; Trusted_Connection=yes"
        'myConnection = New SqlConnection(connStr)

        myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "C:\Program Files\POS\Autopay\Bill\Bill.mdb" & ";")
       myConnection.Open()

        If myConnection.State = 0 Then
            myConnection.Open()
        End If

        CurrentTranxDateTime = Now
        CurrentTranxDate = System.DateTime.Now.ToString("dd-MMM-yyyy")
        CurrentTranxTime = System.DateTime.Now.ToString("hh:mm:ss tt")

        strSQL = "SELECT AgencyName,AccountNo,PaidAmount,TransactionDateTime " _
                & "FROM Update_EPayPaymentDetails " _
                & "WHERE BoothID ='" & BoothNo & "' " _
                & "ORDER BY TransactionDate DESC"

        myCommand = New OleDbCommand(strSQL, myConnection)
        dr = myCommand.ExecuteReader


        Do While dr.Read
            AgencyName = dr(0)
            AccountNo = dr(1)
            PaidAmount = dr(2)
            TransDateTime = dr(3)

            If AgencyName = "Water" Then
                AgencyName = "WATERBILL"
            ElseIf AgencyName = "Elec" Then
                AgencyName = "ELECBILL"
            End If

            'convert to 1 = 100 cent
            PaidAmount = PaidAmount * 100

            requestResponseMsg("", PaidAmount, AgencyName, AccountNo, "etopup", TransDateTime)

                   reconFile("T," & iTotalRecord & "," & Format(dTotalAmount, "0.00"))
                   Loop

                dr.Close()
        myConnection.Close()

    End Function

Hi
One thing I noticed was you commented out the line where you defined dr as as SQLDataReader but I don't see:

dim dr as OleDbDataReader

So how does your code know what dr is supposed to be?

@G Waddell, in the code the dr is declared as OleDbDataReader itself, the error may be instance creation is not done.@Swathys Try using New keyword at the declaration of 'dr'. Hope it will help

commented: thank you +0

thank you i use different declaration of 'dr' and its working fine....

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.