0

Hello I'm using M.Access
I want to get date from database to my datetimepicker, but I got problem

please help, here is my code.

Dim sStatement As String
        sStatement = "SELECT Transactions.RentDate " & _
                     "FROM Transactions INNER JOIN TransactionsDetails ON Transactions.[TransactionID] = TransactionsDetails.[TransactionID]" & _
                     "Where Transactions.MemberID = " & TextBox20.Text & " AND TransactionsDetails.BookID = " & TextBox21.Text & ""
        Try
            Dim sCommand As OleDbCommand = New OleDbCommand(sStatement, sConnection)
            sConnection.Open()
            Dim sReader As OleDbDataReader = sCommand.ExecuteReader()
            DateTimePicker3.Value = Format(sReader(0), "dd/MM/yyyy")
            sConnection.Close()
        Catch sException As System.Exception
            MsgBox(sException.Message, MsgBoxStyle.OkOnly Or MsgBoxStyle.Critical)
        End Try

it always appears

No data exists for the row/column.

But I have many data...
and the second time i click the button

The connection was not closed. The connection's current state is open.

it appears that msg

thanks

2
Contributors
1
Reply
5
Views
7 Years
Discussion Span
Last Post by me655321
0

You need to read a row from the reader before trying to access the contents. sReader.Read()

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.