Results 1 to 5 of 5

Thread: Help with SQL query

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Help with SQL query

    I am having a problem getting my head around a query. What I want it to do is this. I want to be able to list all available rooms of a certain type between 2 dates and display the result is a dgv so that the user can select the available room(s). The information is held in 2 files:

    Calendar
    ---------
    Date
    AccountNumber
    RoomNo
    Status

    Rooms
    ------
    RoomNo
    RoomType

    The 3 fields on the form would be txtArriveDate, txtDepartDate & txtRoomType. I know I can setup a new tableadapter and bind it to the dgv, but it is the query that I am having a problem with.

    Any help on this would be appreciated.

    Computerman
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Help with SQL query

    strSQL = "Select RoomNo,RoomType "
    strSQL &= "From Rooms "
    strSQL &= "Where "
    strSQL &= " RoomType = txtRoomType AND "
    strSQL &= " Status = 'Avail' AND "
    strSQL &= " Date Beteen '" & Me.txtArriveDate.Text &"' AND '" & Me.txtDepartDate & "'"
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  3. #3
    Fanatic Member
    Join Date
    Aug 2009
    Posts
    540

    Re: Help with SQL query

    bad practice with that query, much better off using parameters to protect against any possible sql injection.
    Where I'm from we only have one bit of advice for new comers: "If you hear banjos, turn and run".


    VS 2008 .NetFW 2.0

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2007
    Location
    Somewhere else today
    Posts
    355

    Re: Help with SQL query

    Quote Originally Posted by BackWoodsCoder View Post
    bad practice with that query, much better off using parameters to protect against any possible sql injection.
    What do you mean by that?

    Computerman
    It was much easier in VB6, but I am now liking Vb.Net alot more.

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Help with SQL query

    Quote Originally Posted by computerman View Post
    What do you mean by that?

    Computerman
    Have a look at this FAQ article.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

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