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. Web Development
  3. ASP.NET
  4. how to update sql db table from asp.net

how to update sql db table from asp.net

Scheduled Pinned Locked Moved ASP.NET
databasecsharpasp-nethelptutorial
6 Posts 3 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.
  • P Offline
    P Offline
    potlakayala
    wrote on last edited by
    #1

    Can anyone tell me how to take user input from an application and insert that into SQL database table. I am very new to asp.net. And had tried the below code: insert_cmd = string.Format("Insert into CreateTask(@Title,@AssignedTo,@AssignedDate,@EstimatedEfforts,@Priority)"); // Create new parameters for the SqlCommand object and // initialize them to the input-form field values. mycmd.Parameters.Add(new SqlParameter("@Title", SqlDbType.NText, 11)); mycmd.Parameters["@Title"].Value = inpTitle; The new parameters are created for the other fileds same as above. When I run this program the error displayed as: "The name 'inpTitle' does not exist in the current context"

    Sailaja

    N 1 Reply Last reply
    0
    • P potlakayala

      Can anyone tell me how to take user input from an application and insert that into SQL database table. I am very new to asp.net. And had tried the below code: insert_cmd = string.Format("Insert into CreateTask(@Title,@AssignedTo,@AssignedDate,@EstimatedEfforts,@Priority)"); // Create new parameters for the SqlCommand object and // initialize them to the input-form field values. mycmd.Parameters.Add(new SqlParameter("@Title", SqlDbType.NText, 11)); mycmd.Parameters["@Title"].Value = inpTitle; The new parameters are created for the other fileds same as above. When I run this program the error displayed as: "The name 'inpTitle' does not exist in the current context"

      Sailaja

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

      To Insert into SQL database try following steps 1 - Include System.Data.SqlClient 2 - Intialize SQLConnection class 3 - Set connection string 4 - Create SQLCommand class. You type queries in this class object 5 - Call SQLCommand ExecuteNonQuery() method. Go through some books that explains ADO.NET in detail before you start.


      My Website | Ask smart questions

      P 1 Reply Last reply
      0
      • N N a v a n e e t h

        To Insert into SQL database try following steps 1 - Include System.Data.SqlClient 2 - Intialize SQLConnection class 3 - Set connection string 4 - Create SQLCommand class. You type queries in this class object 5 - Call SQLCommand ExecuteNonQuery() method. Go through some books that explains ADO.NET in detail before you start.


        My Website | Ask smart questions

        P Offline
        P Offline
        potlakayala
        wrote on last edited by
        #3

        hi navaneeth thx for ur reply. I had already written the code for sql connection and all. I am able to connect to sql, after connecting to sql only I am trying to insert the data but the that error msg is being displayed. plz let me know whether i had written the code correctly mentioned earlier?? and also plz send me some refernces if any for learning this....:(

        Sailaja

        N C 2 Replies Last reply
        0
        • P potlakayala

          hi navaneeth thx for ur reply. I had already written the code for sql connection and all. I am able to connect to sql, after connecting to sql only I am trying to insert the data but the that error msg is being displayed. plz let me know whether i had written the code correctly mentioned earlier?? and also plz send me some refernces if any for learning this....:(

          Sailaja

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

          potlakayala wrote:

          plz send me some refernces if any for learning this..

          Check This[^]


          My Website | Ask smart questions

          1 Reply Last reply
          0
          • P potlakayala

            hi navaneeth thx for ur reply. I had already written the code for sql connection and all. I am able to connect to sql, after connecting to sql only I am trying to insert the data but the that error msg is being displayed. plz let me know whether i had written the code correctly mentioned earlier?? and also plz send me some refernces if any for learning this....:(

            Sailaja

            C Offline
            C Offline
            Cfer83
            wrote on last edited by
            #5

            Your SQL insert statement does not appear to be correct. INSERT INTO table(fieldname1,fieldname2,etc) VALUES(value1,value2,etc) WHERE fieldnameX = valueX;

            P 1 Reply Last reply
            0
            • C Cfer83

              Your SQL insert statement does not appear to be correct. INSERT INTO table(fieldname1,fieldname2,etc) VALUES(value1,value2,etc) WHERE fieldnameX = valueX;

              P Offline
              P Offline
              potlakayala
              wrote on last edited by
              #6

              I don't want to give any fixed value in the insert command. I want the command to take the user input values entered from the UI and store those values in the database.

              Sailaja

              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