Results 1 to 7 of 7

Thread: Sql Statement

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Location
    Malaysia
    Posts
    124

    Sql Statement

    I have a table with Column "DateIn" and "DateOut". I want to use a Sql statement to filter out all Rows which DateOut is Empty.
    So..i Use a statement

    Try
    OutSearchIDAdapter1.SelectCommand.CommandText = _
    "SELECT PaperRollID FROM PaperRollTransaction WHERE " & _
    "DateOut = '""' " & _
    "ORDER BY PaperRollID ASC"
    OutSearchIDAdapter1.Fill(OutSearchIDDataSet11)

    Catch oledbdataexception As System.Data.OleDb.OleDbException
    MessageBox.Show(oledbdataexception.Message)
    End Try

    The above statement is giving me an error message. I know that my Sql statement has error in WHERE clause. So..just wonder how do i filter out the Empty Column in Access Table.

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Try...

    "SELECT PaperRollID FROM PaperRollTransaction WHERE " & _
    "DateOut Is Null " & _
    "ORDER BY PaperRollID ASC"

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Location
    Malaysia
    Posts
    124

    Thanks, but another problem

    I got it!, anywhere thanks.

    I have another question, Example, i have many date values inside the table; 11/23/2002, 11/24/2002, 11/25/2002, 12/12/2002, 12/14/2002, 12/25/2002. how to i just filter out records on monthly basic?

    For Instance, I wan the records on Dec / 2002.

  4. #4
    Addicted Member CoMMiE's Avatar
    Join Date
    Jul 2000
    Location
    Malaysia, Kuala Lumpur
    Posts
    179
    hi maybe you could try this:
    Select from tablename where date>= '"& 12/1/2002 & "'and Date <= '" & 12/31/2002 & "'"

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Location
    Malaysia
    Posts
    124

    Commie..Thanks, but this is not what i want

    i wan to do it in a flexible way, i would have 2 text/combo box to select MONTH and YEAR, respectively.

  6. #6
    Addicted Member CoMMiE's Avatar
    Join Date
    Jul 2000
    Location
    Malaysia, Kuala Lumpur
    Posts
    179
    In that case you could try doing this

    Select from tablename where date= '"& comboboxmonth.text &"/1/"& comboboxYear.text &"'"

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Location
    Malaysia
    Posts
    124

    Why /1/ ?

    Will it filter out only 1/1, 2/1, 3/1 ... 12/1??

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