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

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

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.