Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Help with an SQL statement...

Help with an SQL statement...

Scheduled Pinned Locked Moved Visual Basic
helpdatabasetutorialquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CCG3
    wrote on last edited by
    #1

    I just need to know how to pass my Date over with the # sign on each side of it. If I run this in the Qurey Builder it works as long as I put # on each side of my date. So it needs to look something like this.... SQL = "DELETE FROM Pat20VisitDate WHERE (VisitMRNo = '" & MR & "') AND (VisitDate = "& #SelectedVisitDate# &")" but I have the syntax wrong or something. Is this some type of formatting issue? Does anyone have any suggestions? Thanks in advance!

    D 2 Replies Last reply
    0
    • C CCG3

      I just need to know how to pass my Date over with the # sign on each side of it. If I run this in the Qurey Builder it works as long as I put # on each side of my date. So it needs to look something like this.... SQL = "DELETE FROM Pat20VisitDate WHERE (VisitMRNo = '" & MR & "') AND (VisitDate = "& #SelectedVisitDate# &")" but I have the syntax wrong or something. Is this some type of formatting issue? Does anyone have any suggestions? Thanks in advance!

      D Offline
      D Offline
      Dave Herren
      wrote on last edited by
      #2

      I believe you want this. SQL = "DELETE FROM Pat20VisitDate WHERE (VisitMRNo = '" & MR & "') AND (VisitDate = #"& SelectedVisitDate &"#)"

      topcoderjax - Remember, Google is your friend.

      1 Reply Last reply
      0
      • C CCG3

        I just need to know how to pass my Date over with the # sign on each side of it. If I run this in the Qurey Builder it works as long as I put # on each side of my date. So it needs to look something like this.... SQL = "DELETE FROM Pat20VisitDate WHERE (VisitMRNo = '" & MR & "') AND (VisitDate = "& #SelectedVisitDate# &")" but I have the syntax wrong or something. Is this some type of formatting issue? Does anyone have any suggestions? Thanks in advance!

        D Offline
        D Offline
        Dave Herren
        wrote on last edited by
        #3

        Oh and sorry that I never got around to checking back on your post from yesterday. It's been a busy day.

        topcoderjax - Remember, Google is your friend.

        C 1 Reply Last reply
        0
        • D Dave Herren

          Oh and sorry that I never got around to checking back on your post from yesterday. It's been a busy day.

          topcoderjax - Remember, Google is your friend.

          C Offline
          C Offline
          CCG3
          wrote on last edited by
          #4

          Yes you are right about that SQL statement. I just had the # in the wrong place. I went back to my code and just tried everything until I got it. Don't worry about not getting back to me. I got it figured out. Thanks for your help!!

          C D 2 Replies Last reply
          0
          • C CCG3

            Yes you are right about that SQL statement. I just had the # in the wrong place. I went back to my code and just tried everything until I got it. Don't worry about not getting back to me. I got it figured out. Thanks for your help!!

            C Offline
            C Offline
            Colin Angus Mackay
            wrote on last edited by
            #5

            CCG3 wrote:

            Yes you are right about that SQL statement

            But with that SQL Statement you are opening a big wide gaping security hole in your application. Read SQL Injection Attacks and Tips on How to Prevent Them[^]


            Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

            1 Reply Last reply
            0
            • C CCG3

              Yes you are right about that SQL statement. I just had the # in the wrong place. I went back to my code and just tried everything until I got it. Don't worry about not getting back to me. I got it figured out. Thanks for your help!!

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              If you used parameterized queries, you wouldn't have to worrdy about things like making sure the date is in the correct format, or if the # characters are in the correct place, or escaping other data in your parameters, ...

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups