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. C#
  4. syntax error

syntax error

Scheduled Pinned Locked Moved C#
databasehelp
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.
  • M Offline
    M Offline
    myinstincts
    wrote on last edited by
    #1

    i am inserting values of useridtxtbx and pwdtxtbx to database on submitbtn_click.Insert statement is not showing error while debugging ..but when the program runs it is giving syntax error..Below is my code protected void submitbtn_Click(object sender, EventArgs e) { OleDbConnection con= new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source = C:\\Documents and Settings\\swuser\\My Documents\\Clinical_Billing.mdb;" ); con.Open(); OleDbCommand cmd = new OleDbCommand("insert into user_login(user_id,password) values('" + useridtxtbx.Text + "','" + pwdtxtbx.Text + "'", con); cmd.ExecuteNonQuery(); con.Close(); }

    N A L 3 Replies Last reply
    0
    • M myinstincts

      i am inserting values of useridtxtbx and pwdtxtbx to database on submitbtn_click.Insert statement is not showing error while debugging ..but when the program runs it is giving syntax error..Below is my code protected void submitbtn_Click(object sender, EventArgs e) { OleDbConnection con= new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source = C:\\Documents and Settings\\swuser\\My Documents\\Clinical_Billing.mdb;" ); con.Open(); OleDbCommand cmd = new OleDbCommand("insert into user_login(user_id,password) values('" + useridtxtbx.Text + "','" + pwdtxtbx.Text + "'", con); cmd.ExecuteNonQuery(); con.Close(); }

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Use parameterized queries. You should be good then.

      Navaneeth How to use google | Ask smart questions

      1 Reply Last reply
      0
      • M myinstincts

        i am inserting values of useridtxtbx and pwdtxtbx to database on submitbtn_click.Insert statement is not showing error while debugging ..but when the program runs it is giving syntax error..Below is my code protected void submitbtn_Click(object sender, EventArgs e) { OleDbConnection con= new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source = C:\\Documents and Settings\\swuser\\My Documents\\Clinical_Billing.mdb;" ); con.Open(); OleDbCommand cmd = new OleDbCommand("insert into user_login(user_id,password) values('" + useridtxtbx.Text + "','" + pwdtxtbx.Text + "'", con); cmd.ExecuteNonQuery(); con.Close(); }

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        myinstincts wrote:

        new OleDbCommand("insert into user_login(user_id,password) values('" + useridtxtbx.Text + "','" + pwdtxtbx.Text + "'", con);

        As Navaneeth, suggested try to avoid code like that. It will caused SQL Injection Problem. Use Parameterized Query.

        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

        modified on Saturday, September 5, 2009 3:50 AM

        M 1 Reply Last reply
        0
        • A Abhijit Jana

          myinstincts wrote:

          new OleDbCommand("insert into user_login(user_id,password) values('" + useridtxtbx.Text + "','" + pwdtxtbx.Text + "'", con);

          As Navaneeth, suggested try to avoid code like that. It will caused SQL Injection Problem. Use Parameterized Query.

          Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

          modified on Saturday, September 5, 2009 3:50 AM

          M Offline
          M Offline
          myinstincts
          wrote on last edited by
          #4

          this is the first time i am hearing of anything like parameterized query and sql injection problem...thanks for those valuable informations...i will try with those then

          A 1 Reply Last reply
          0
          • M myinstincts

            this is the first time i am hearing of anything like parameterized query and sql injection problem...thanks for those valuable informations...i will try with those then

            A Offline
            A Offline
            Abhijit Jana
            wrote on last edited by
            #5

            Please read this article, SQL Injection Attacks and Some Tips on How to Prevent Them[^]

            Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

            1 Reply Last reply
            0
            • M myinstincts

              i am inserting values of useridtxtbx and pwdtxtbx to database on submitbtn_click.Insert statement is not showing error while debugging ..but when the program runs it is giving syntax error..Below is my code protected void submitbtn_Click(object sender, EventArgs e) { OleDbConnection con= new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source = C:\\Documents and Settings\\swuser\\My Documents\\Clinical_Billing.mdb;" ); con.Open(); OleDbCommand cmd = new OleDbCommand("insert into user_login(user_id,password) values('" + useridtxtbx.Text + "','" + pwdtxtbx.Text + "'", con); cmd.ExecuteNonQuery(); con.Close(); }

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              hi, 1. the values parenthesis isn't closed 2. you shouldn't store plain passwords in a database, if it gets hacked all the entries become worthless at once. :)

              Luc Pattyn

              :badger: :jig: :badger:

              Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.

              :jig: :badger: :jig:

              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