Click here to Skip to main content
15,914,452 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm using vb.net and oracle as my database
how i'm going to search a date for a day only by using basic date picker which i assign as bdp1 ?

this is my basic code

VB
Private Function GetDate( ByVal bdp1 As date) As DataSet

        Dim connectionString As String = "Data Source = abc; User ID = ***; Password = ***;"
        Dim sqlConnection As OracleClient.OracleConnection = New OracleClient.OracleConnection(connectionString)


        Dim queryString As String = "select * from table_abc where (column_name<= to_date( 'user_input' ,'MM/DD/YYYY') and column_name > to_date( 'user_input' ,'MM/DD/YYYY')

        Dim sqlCommand As OracleClient.OracleCommand = New OracleClient.OracleCommand(queryString, sqlConnection)
        sqlCommand.CommandTimeout = 0

        sqlCommand.Parameters.Add(New OracleParameter(":bdp1", OracleType.DateTime)).Value = bdp1


        Dim dataAdapter As OracleClient.OracleDataAdapter = New OracleClient.OracleDataAdapter(sqlCommand)
        Dim dataSet As DataSet = New DataSet
        dataAdapter.Fill(dataSet)

        Return dataSet

    End Function
Posted
Updated 11-Jun-13 21:50pm
v3

1 solution

In this initially save the date in a integer format like ( if date is 03/04/2013 then save it as 20130403). after then you used the between like below code You will get it









SELECT M.REGNO FROM MSTPATINDX M WHERE M.ADMNDATE BETWEEN '" & frmdate & "' AND '" & todate & "'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900