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. CSharp oleDB - INSERT INTO

CSharp oleDB - INSERT INTO

Scheduled Pinned Locked Moved C#
databasecsharpcomsecuritydebugging
9 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.
  • I Offline
    I Offline
    Idoshhh
    wrote on last edited by
    #1

    Hi, i've got a problem when i tried to INSERT details to OLEDB Access. this is my code: <pre> public class registrationClass       {             static string connStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\WebSites\DB\users.mdb;Persist Security Info=True";             public static string details(string username, string pass, string email)             {                   string input;                   //bool Enter = true;                                           OleDbConnection conn = new OleDbConnection(connStr);                   conn.Open();                   input = String.Format(@"INSERT INTO userAuth (user,password,Email) VALUES ('{0}','{1}','{2}')", username, pass, email);                                          OleDbCommand cmd = new OleDbCommand(input, conn);                   cmd.ExecuteNonQuery();                   conn.Close();                   return String.Format("Done");             } </pre> now, when i searched on the web, i saw that my query is well. when i did debug to this action, the input looks like: "INSERT INTO userAuth (user,password,Email) VALUES ('Igor','pass123','igor@email.com')" whats wrong???????? thank u!!!

    L 1 Reply Last reply
    0
    • I Idoshhh

      Hi, i've got a problem when i tried to INSERT details to OLEDB Access. this is my code: <pre> public class registrationClass       {             static string connStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\WebSites\DB\users.mdb;Persist Security Info=True";             public static string details(string username, string pass, string email)             {                   string input;                   //bool Enter = true;                                           OleDbConnection conn = new OleDbConnection(connStr);                   conn.Open();                   input = String.Format(@"INSERT INTO userAuth (user,password,Email) VALUES ('{0}','{1}','{2}')", username, pass, email);                                          OleDbCommand cmd = new OleDbCommand(input, conn);                   cmd.ExecuteNonQuery();                   conn.Close();                   return String.Format("Done");             } </pre> now, when i searched on the web, i saw that my query is well. when i did debug to this action, the input looks like: "INSERT INTO userAuth (user,password,Email) VALUES ('Igor','pass123','igor@email.com')" whats wrong???????? thank u!!!

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

      Ido Shahar wrote:

      i've got a problem

      Do you? which problem? what are the symptoms? does it compile? does it run? does it throw an exception? which exception? at what line? does your SQL statement work for you when entered in Access itself? :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


      T I 2 Replies Last reply
      0
      • L Luc Pattyn

        Ido Shahar wrote:

        i've got a problem

        Do you? which problem? what are the symptoms? does it compile? does it run? does it throw an exception? which exception? at what line? does your SQL statement work for you when entered in Access itself? :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


        T Offline
        T Offline
        tom572007
        wrote on last edited by
        #3

        +1

        1 Reply Last reply
        0
        • L Luc Pattyn

          Ido Shahar wrote:

          i've got a problem

          Do you? which problem? what are the symptoms? does it compile? does it run? does it throw an exception? which exception? at what line? does your SQL statement work for you when entered in Access itself? :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in


          I Offline
          I Offline
          Idoshhh
          wrote on last edited by
          #4

          You right, i didnt write any descriptions of symptoms. i've got an Exception about "Syntax error in INSERT INTO statement" in Line "cmd.ExecuteNonQuery();" 10x

          L 1 Reply Last reply
          0
          • I Idoshhh

            You right, i didnt write any descriptions of symptoms. i've got an Exception about "Syntax error in INSERT INTO statement" in Line "cmd.ExecuteNonQuery();" 10x

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

            When you enter the exact error message ("Syntax error in INSERT INTO statement") in Google, the first hit explains what is wrong. So learn to Google, it often solves your problem in a matter of seconds. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


            I 1 Reply Last reply
            0
            • L Luc Pattyn

              When you enter the exact error message ("Syntax error in INSERT INTO statement") in Google, the first hit explains what is wrong. So learn to Google, it often solves your problem in a matter of seconds. :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


              I Offline
              I Offline
              Idoshhh
              wrote on last edited by
              #6

              wtf! it wasnt necessary to say what u said. i have googled it, and also tried to changed password to [password] but also, i've got an exception! bye

              L L 2 Replies Last reply
              0
              • I Idoshhh

                wtf! it wasnt necessary to say what u said. i have googled it, and also tried to changed password to [password] but also, i've got an exception! bye

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                lol @ wtf!

                Check out the CodeProject forum Guidelines[^]

                1 Reply Last reply
                0
                • I Idoshhh

                  wtf! it wasnt necessary to say what u said. i have googled it, and also tried to changed password to [password] but also, i've got an exception! bye

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

                  is it a PebkacException? :)

                  Luc Pattyn [Forum Guidelines] [My Articles]


                  The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


                  I 1 Reply Last reply
                  0
                  • L Luc Pattyn

                    is it a PebkacException? :)

                    Luc Pattyn [Forum Guidelines] [My Articles]


                    The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


                    I Offline
                    I Offline
                    Idoshhh
                    wrote on last edited by
                    #9

                    ok, I got it!!!! the problem was the column names and the way of writing. the fixed is: <code> input = @"INSERT INTO userAuth ([user], [pass], [mail]) VALUES ('" + username + "', '" + pass + "', '" + email + "') "; </code> and the parameters that i sending is after casting ToString(), also, in the DB i changed the Column rule to string and not email column as i defined before. thanks to everyone. ido.

                    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