Results 1 to 4 of 4

Thread: [2005] Anything less than a value?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    [2005] Anything less than a value?

    As per the code:
    Code:
                Using command As New MySql.Data.MySqlClient.MySqlCommand("select NextDue from Company_ID where NextDue = '" & todaysdate & "'", connection)
    Where todaysdate is, I actually want it to look for anything less than that. Any ideas?

    I was trying "& < todaysdate &", but it needs something before it to reference off of.

    In a sense, the program is looking for dates that are were due before today's date.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Anything less than a value?

    Look at your code:
    Code:
    NextDue = '" & todaysdate & "'"
    If you want to get values less than, intead of equal to, the value then would you not just replace the = with <? Why would the less than sign go outside the double quotes when the equal sign is inside?
    Code:
    NextDue < '" & todaysdate & "'"
    That said, you should NOT be using string concatenation to build SQL statements. You should be using parameters, which is the proper way:
    vb.net Code:
    1. Using command As New MySqlCommand("SELECT NextDue FROM Company_ID WHERE NextDue < ?Today", connection)
    2.     command.Parameters.AddWithValue("?Today", Date.Today)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2007
    Posts
    520

    Re: [2005] Anything less than a value?

    I didnt think you could use a < instead of = in a MySQL statement.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Anything less than a value?

    Quote Originally Posted by TCarter
    I didnt think you could use a < instead of = in a MySQL statement.
    Hmmm... I've never used MySQL so I couldn't say. I just assumed. Maybe you're right but I find it difficult to believe that an enterprise grade database like MySQL wouldn't support a less than operator.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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