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. insert & update problem

insert & update problem

Scheduled Pinned Locked Moved ASP.NET
databasecsharpasp-nethelpannouncement
8 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.
  • K Offline
    K Offline
    kal13na13
    wrote on last edited by
    #1

    hi In my project of asp.net and C# i am entering the values in the textboxes and clicking submit button which allows inserting and updation in the same click event i am not using stored procedures for insertion and updation. The problem is that now if i click submit button neither it is getting inserted and updated in the database .Can anyone give me idea what i am suppose to do i dont want to use stored procedure only use a simple sql query. Thanks in advance kal13na13 -- modified at 3:54 Tuesday 13th December, 2005

    _ 1 Reply Last reply
    0
    • K kal13na13

      hi In my project of asp.net and C# i am entering the values in the textboxes and clicking submit button which allows inserting and updation in the same click event i am not using stored procedures for insertion and updation. The problem is that now if i click submit button neither it is getting inserted and updated in the database .Can anyone give me idea what i am suppose to do i dont want to use stored procedure only use a simple sql query. Thanks in advance kal13na13 -- modified at 3:54 Tuesday 13th December, 2005

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

      Can u plz provide us with the code u r writing in the click event Regards _mubashir

      K 1 Reply Last reply
      0
      • _ _mubashir

        Can u plz provide us with the code u r writing in the click event Regards _mubashir

        K Offline
        K Offline
        kal13na13
        wrote on last edited by
        #3

        here is the code : string strSelect= "Insert into Table1 (Name,Age,Gender) values (?,?,?)"; SqlCommand cmd=new SqlCommand(strSelect,sqlConnection1); sqlConnection1.Open(); cmd.ExecuteNonQuery(); sqlConnection1.Close(); Label1.Text = "Your data has been received!"; //code for the update string updateString = "UPDATE Table1 SET " + "Name='?',Age='?',Gender='?' " + "WHERE Number='?'"; SqlCommand mycmd = new SqlCommand(updateString,sqlConnection1); sqlConnection1.Open(); mycmd.ExecuteNonQuery(); sqlConnection1.Close(); Server.Transfer("Print.aspx"); kal13na13 -- modified at 4:21 Tuesday 13th December, 2005

        G 1 Reply Last reply
        0
        • K kal13na13

          here is the code : string strSelect= "Insert into Table1 (Name,Age,Gender) values (?,?,?)"; SqlCommand cmd=new SqlCommand(strSelect,sqlConnection1); sqlConnection1.Open(); cmd.ExecuteNonQuery(); sqlConnection1.Close(); Label1.Text = "Your data has been received!"; //code for the update string updateString = "UPDATE Table1 SET " + "Name='?',Age='?',Gender='?' " + "WHERE Number='?'"; SqlCommand mycmd = new SqlCommand(updateString,sqlConnection1); sqlConnection1.Open(); mycmd.ExecuteNonQuery(); sqlConnection1.Close(); Server.Transfer("Print.aspx"); kal13na13 -- modified at 4:21 Tuesday 13th December, 2005

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          You haven't added any parameters to the commands, although you specify parameters in the queries. That code should produce an exception. Do you say that it doesn't? --- b { font-weight: normal; }

          K 1 Reply Last reply
          0
          • G Guffa

            You haven't added any parameters to the commands, although you specify parameters in the queries. That code should produce an exception. Do you say that it doesn't? --- b { font-weight: normal; }

            K Offline
            K Offline
            kal13na13
            wrote on last edited by
            #5

            its not rasing any exception ,page is displayed i am able to enter values click submit button no response the same page is there with the data. is there any way i can insert and update data without stored procedures and parameters? thanks kal13na13

            G 1 Reply Last reply
            0
            • K kal13na13

              its not rasing any exception ,page is displayed i am able to enter values click submit button no response the same page is there with the data. is there any way i can insert and update data without stored procedures and parameters? thanks kal13na13

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              Are you sure that the code you show is executed at all?

              kal13na13 wrote:

              is there any way i can insert and update data without stored procedures and parameters?

              Yes, you can use a query without parameters. --- b { font-weight: normal; }

              K 1 Reply Last reply
              0
              • G Guffa

                Are you sure that the code you show is executed at all?

                kal13na13 wrote:

                is there any way i can insert and update data without stored procedures and parameters?

                Yes, you can use a query without parameters. --- b { font-weight: normal; }

                K Offline
                K Offline
                kal13na13
                wrote on last edited by
                #7

                yes its getting excuted the page is displayed values are entered the moment submit button is clicked nothing happens Can you tell me how i can achieve updation and insertion queries without use of parameters any good websites. kal13na13 -- modified at 0:06 Wednesday 14th December, 2005

                G 1 Reply Last reply
                0
                • K kal13na13

                  yes its getting excuted the page is displayed values are entered the moment submit button is clicked nothing happens Can you tell me how i can achieve updation and insertion queries without use of parameters any good websites. kal13na13 -- modified at 0:06 Wednesday 14th December, 2005

                  G Offline
                  G Offline
                  Guffa
                  wrote on last edited by
                  #8

                  kal13na13 wrote:

                  yes its getting excuted the page is displayed values are entered the moment submit button is clicked nothing happens

                  If you would have used any punctuation, that sentence (or sentences?) could have been possible to understand. --- b { font-weight: normal; }

                  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