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. inserting a row into table from the form data

inserting a row into table from the form data

Scheduled Pinned Locked Moved Database
databasequestionsql-serversysadminhelp
4 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.
  • R Offline
    R Offline
    Raheem MA
    wrote on last edited by
    #1

    Hi Friend'z... I want to enter a row data to the sql server table, from the data entered by the user in the windows form. I hav a query string str="insert into books values ("+'@textBox1.Text'+","+'@textBox2.Text'+")"; what is wrong in this? pl help me in doing.... thanks in advance :):confused:

    _ K I 3 Replies Last reply
    0
    • R Raheem MA

      Hi Friend'z... I want to enter a row data to the sql server table, from the data entered by the user in the windows form. I hav a query string str="insert into books values ("+'@textBox1.Text'+","+'@textBox2.Text'+")"; what is wrong in this? pl help me in doing.... thanks in advance :):confused:

      _ Offline
      _ Offline
      _mubashir
      wrote on last edited by
      #2

      Write down the query with actual values...Best way is to run in debug mode and then see wat is the actual query in str variable. Mubashir

      Every job is a self portrait of the person who did it.

      1 Reply Last reply
      0
      • R Raheem MA

        Hi Friend'z... I want to enter a row data to the sql server table, from the data entered by the user in the windows form. I hav a query string str="insert into books values ("+'@textBox1.Text'+","+'@textBox2.Text'+")"; what is wrong in this? pl help me in doing.... thanks in advance :):confused:

        K Offline
        K Offline
        Krish KP
        wrote on last edited by
        #3

        hope the two values you are trying to insert are strings then the statement should be ... string str = "INSERT INTO books VALUES ('" + textBox1.text + "', '" + textBox2.text + "')"

        Regards KP

        1 Reply Last reply
        0
        • R Raheem MA

          Hi Friend'z... I want to enter a row data to the sql server table, from the data entered by the user in the windows form. I hav a query string str="insert into books values ("+'@textBox1.Text'+","+'@textBox2.Text'+")"; what is wrong in this? pl help me in doing.... thanks in advance :):confused:

          I Offline
          I Offline
          Ian Dennis
          wrote on last edited by
          #4

          Try SQLstr="insert into books ({col1}, {col2}) values ('" & textBox1.Text & "', '" & textBox2.Text & "')"; (This is VB ... I'm not sure what language you're using ... the important thing is the {col1} and {col2} which are the names of the table colums that @textBox1 and @textBox2 are going to be inserted into) I find that a good debug tip is to use Query Analyser to test the structure of my SQL statement before I insert it into code. So I would try something like INSERT INTO books VALUES ('SQL Programming', 'Robert Vieira') and when that didn't work I'd try INSERT INTO books (title, author) VALUES ('SQL Programming', 'Robert Vieira')

          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