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. Database & SysAdmin
  3. Database
  4. Insert Function Inserts Only Parameternames

Insert Function Inserts Only Parameternames

Scheduled Pinned Locked Moved Database
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.
  • A Offline
    A Offline
    ASPnoob
    wrote on last edited by
    #1

    Hi all, I'm trying to insert info from text boxes into an Access database using a stored procedure and it seems to some what work. The only problem is values from the text boxes are not entered into the database, instead the parameter names are inserted into the database. The following are how I named, set, and added all my parameters: param = new OleDbParameter("@myvalue", value); oCommand.Parameters.Add(param); My stored procedure takes the following form: INSERT INTO Table( field1,field2) VALUES ('@value1', '@value2'); I have also tried naming, setting, and adding all my parameters using the below method which gave the same exact result as the above method: param = new OleDbParameter(); param.ParameterName="@myvalue"; param.Value=value; oCommand.Parameters.Add(param); Please point out what the problem is if you can spot it, thanks.

    R P 2 Replies Last reply
    0
    • A ASPnoob

      Hi all, I'm trying to insert info from text boxes into an Access database using a stored procedure and it seems to some what work. The only problem is values from the text boxes are not entered into the database, instead the parameter names are inserted into the database. The following are how I named, set, and added all my parameters: param = new OleDbParameter("@myvalue", value); oCommand.Parameters.Add(param); My stored procedure takes the following form: INSERT INTO Table( field1,field2) VALUES ('@value1', '@value2'); I have also tried naming, setting, and adding all my parameters using the below method which gave the same exact result as the above method: param = new OleDbParameter(); param.ParameterName="@myvalue"; param.Value=value; oCommand.Parameters.Add(param); Please point out what the problem is if you can spot it, thanks.

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      INSERT INTO Table( field1,field2)
      VALUES (@value1, @value2);

      You don't need the quotes or they'll be interpreted as literal strings.

      "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

      A 1 Reply Last reply
      0
      • R R Giskard Reventlov

        INSERT INTO Table( field1,field2)
        VALUES (@value1, @value2);

        You don't need the quotes or they'll be interpreted as literal strings.

        "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

        A Offline
        A Offline
        ASPnoob
        wrote on last edited by
        #3

        Hi Mark, thanks for replying I've already tried using no quote, single and double quotes without much luck. However, I've just found out that since I'm using Access, I have to use square brackets. My problem is now solved.

        R 1 Reply Last reply
        0
        • A ASPnoob

          Hi all, I'm trying to insert info from text boxes into an Access database using a stored procedure and it seems to some what work. The only problem is values from the text boxes are not entered into the database, instead the parameter names are inserted into the database. The following are how I named, set, and added all my parameters: param = new OleDbParameter("@myvalue", value); oCommand.Parameters.Add(param); My stored procedure takes the following form: INSERT INTO Table( field1,field2) VALUES ('@value1', '@value2'); I have also tried naming, setting, and adding all my parameters using the below method which gave the same exact result as the above method: param = new OleDbParameter(); param.ParameterName="@myvalue"; param.Value=value; oCommand.Parameters.Add(param); Please point out what the problem is if you can spot it, thanks.

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          ASPnoob wrote:

          VALUES ('@value1', '@value2'); ... param.ParameterName="@myvalue";

          As mentioned, remove the apostrophes. The names have to match as well.

          1 Reply Last reply
          0
          • A ASPnoob

            Hi Mark, thanks for replying I've already tried using no quote, single and double quotes without much luck. However, I've just found out that since I'm using Access, I have to use square brackets. My problem is now solved.

            R Offline
            R Offline
            R Giskard Reventlov
            wrote on last edited by
            #5

            Really? How bizarre. Years and years since I used it and I don't recall having to do that. Oh well, relearn something, err, old, every day...

            "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

            L 1 Reply Last reply
            0
            • R R Giskard Reventlov

              Really? How bizarre. Years and years since I used it and I don't recall having to do that. Oh well, relearn something, err, old, every day...

              "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

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

              mark merrens wrote:

              Really? How bizarre.

              VALUE is a reserved keyword; it would be like having a variable called "SELECT".

              Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

              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