Results 1 to 5 of 5

Thread: Querying in Oracle databse from date time picker using parameters

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2018
    Posts
    90

    Querying in Oracle databse from date time picker using parameters

    hi Sir,

    I try code below to query data from my oracle database base on the 2 date time picker .using parameters but i got an error message."missing expression"
    please suggest where i made a mistakes
    thanks .

    Code:
       Public Sub loadQuery()
            Dim startDate = dtpFrom.Value.Date
            Dim endDate = dtpTo.Value.Date.AddDays(1)
    
            Try
                conn.Open()
                cmd.Connection = conn
                cmd.CommandType = CommandType.Text
                dataAdaptor.SelectCommand = cmd
                cmd.CommandText = ("select * from test_table where ERR_DTTM >= @startDate and ERR_DTTM < @endDAte")
                cmd.Parameters.AddWithValue("@startDate", dtpFrom.Value.Date)
                cmd.Parameters.AddWithValue("@endDate", dtpTo.Value.Date.AddDays(1))
                Dim dr As OleDbDataReader = cmd.ExecuteReader
                If dr.HasRows Then
                    datatable.Load(dr)
                    dgvWCQ.DataSource = datatable
                Else
                    MsgBox("no data")
    
                End If
    
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub
    my program interface
    Name:  ccc.jpg
Views: 578
Size:  15.9 KB
    Attached Images Attached Images  

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width