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. not able to insert the values

not able to insert the values

Scheduled Pinned Locked Moved ASP.NET
csharphelpasp-netsysadminsecurity
9 Posts 5 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.
  • S Offline
    S Offline
    sumanmks
    wrote on last edited by
    #1

    hi i am very new to asp.net. It may be the simplest problem to u. but for me it is a bit difficult. I have written a code for inserting the values in the SQLEXPRESS in C#.but not able to insert it. Can Any one help me out. the code is as follows: protected void Button1_Click1(object sender, EventArgs e) { SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = @"Data Source=localhost\SQLEXPRESS;" + "Initial Catalog=testdata;Integrated Security=SSPI"; try { myConnection.Open(); Label1.Text = "<b>Server Version:</b> " + myConnection.ServerVersion; Label1.Text += "<br /><b>Connection Is:</b> " + myConnection.State.ToString(); string insertSQL; insertSQL = "INSERT INTO jobseekerinfo ("; insertSQL += "firstname, middlename, lastname, "; insertSQL += "dob, address, city, state, zip, mobile, phone, engcollege, "; insertSQL += "enguniversity, engaggergate, pucollege, puuniversity, pumarks,"; insertSQL += "school, scuniversity, scmarks, totalyears, totalmonths,"; insertSQL += "workplace, job, skills"; insertSQL += "VALUES ('"; insertSQL += TextBox1.Text + "', '"; insertSQL += TextBox2.Text + "', '"; insertSQL += TextBox3.Text + "', '"; insertSQL += TextBox29.Text + "', '"; insertSQL += TextBox5.Text + "', '"; insertSQL += TextBox11.Text + "', '"; insertSQL += TextBox12.Text + "', '"; insertSQL += TextBox14.Text + "', '"; insertSQL += TextBox6.Text + "', '"; insertSQL += TextBox15.Text + "', '"; insertSQL += TextBox4.Text + "', '"; insertSQL += TextBox8.Text + "', '"; insertSQL += TextBox9.Text + "', '"; insertSQL += TextBox10.Text + "', '"; insertSQL += TextBox30.Text + "', '"; insertSQL += TextBox31.Text + "', '"; insertSQL += TextBox32.Text + "', '"; insertSQL += TextBox33.Text + "', '"; insertSQL += TextBox34.Text + "', '"; insertSQL += TextBox35.Text + "', '"; insertSQL += TextBox36.Text + "', '"; insertSQL += TextBox18.Text

    G P K S 4 Replies Last reply
    0
    • S sumanmks

      hi i am very new to asp.net. It may be the simplest problem to u. but for me it is a bit difficult. I have written a code for inserting the values in the SQLEXPRESS in C#.but not able to insert it. Can Any one help me out. the code is as follows: protected void Button1_Click1(object sender, EventArgs e) { SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = @"Data Source=localhost\SQLEXPRESS;" + "Initial Catalog=testdata;Integrated Security=SSPI"; try { myConnection.Open(); Label1.Text = "<b>Server Version:</b> " + myConnection.ServerVersion; Label1.Text += "<br /><b>Connection Is:</b> " + myConnection.State.ToString(); string insertSQL; insertSQL = "INSERT INTO jobseekerinfo ("; insertSQL += "firstname, middlename, lastname, "; insertSQL += "dob, address, city, state, zip, mobile, phone, engcollege, "; insertSQL += "enguniversity, engaggergate, pucollege, puuniversity, pumarks,"; insertSQL += "school, scuniversity, scmarks, totalyears, totalmonths,"; insertSQL += "workplace, job, skills"; insertSQL += "VALUES ('"; insertSQL += TextBox1.Text + "', '"; insertSQL += TextBox2.Text + "', '"; insertSQL += TextBox3.Text + "', '"; insertSQL += TextBox29.Text + "', '"; insertSQL += TextBox5.Text + "', '"; insertSQL += TextBox11.Text + "', '"; insertSQL += TextBox12.Text + "', '"; insertSQL += TextBox14.Text + "', '"; insertSQL += TextBox6.Text + "', '"; insertSQL += TextBox15.Text + "', '"; insertSQL += TextBox4.Text + "', '"; insertSQL += TextBox8.Text + "', '"; insertSQL += TextBox9.Text + "', '"; insertSQL += TextBox10.Text + "', '"; insertSQL += TextBox30.Text + "', '"; insertSQL += TextBox31.Text + "', '"; insertSQL += TextBox32.Text + "', '"; insertSQL += TextBox33.Text + "', '"; insertSQL += TextBox34.Text + "', '"; insertSQL += TextBox35.Text + "', '"; insertSQL += TextBox36.Text + "', '"; insertSQL += TextBox18.Text

      G Offline
      G Offline
      Greg Chelstowski
      wrote on last edited by
      #2

      Even though this is madness, i think it's going to work when you close the bracket here: insertSQL += "workplace, job, skills"; insertSQL+=") "; insertSQL += "VALUES ('"; and get rid of the comma here: insertSQL += TextBox20.Text; What I really want to say is, before bothering other people, DEBUG your project. Oh, and once you've done it, and your project inserts your data, read up on sql injection. And parameterized queries. And how to store your connection string in web.config.

      var question = (_2b || !(_2b));

      1 Reply Last reply
      0
      • S sumanmks

        hi i am very new to asp.net. It may be the simplest problem to u. but for me it is a bit difficult. I have written a code for inserting the values in the SQLEXPRESS in C#.but not able to insert it. Can Any one help me out. the code is as follows: protected void Button1_Click1(object sender, EventArgs e) { SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = @"Data Source=localhost\SQLEXPRESS;" + "Initial Catalog=testdata;Integrated Security=SSPI"; try { myConnection.Open(); Label1.Text = "<b>Server Version:</b> " + myConnection.ServerVersion; Label1.Text += "<br /><b>Connection Is:</b> " + myConnection.State.ToString(); string insertSQL; insertSQL = "INSERT INTO jobseekerinfo ("; insertSQL += "firstname, middlename, lastname, "; insertSQL += "dob, address, city, state, zip, mobile, phone, engcollege, "; insertSQL += "enguniversity, engaggergate, pucollege, puuniversity, pumarks,"; insertSQL += "school, scuniversity, scmarks, totalyears, totalmonths,"; insertSQL += "workplace, job, skills"; insertSQL += "VALUES ('"; insertSQL += TextBox1.Text + "', '"; insertSQL += TextBox2.Text + "', '"; insertSQL += TextBox3.Text + "', '"; insertSQL += TextBox29.Text + "', '"; insertSQL += TextBox5.Text + "', '"; insertSQL += TextBox11.Text + "', '"; insertSQL += TextBox12.Text + "', '"; insertSQL += TextBox14.Text + "', '"; insertSQL += TextBox6.Text + "', '"; insertSQL += TextBox15.Text + "', '"; insertSQL += TextBox4.Text + "', '"; insertSQL += TextBox8.Text + "', '"; insertSQL += TextBox9.Text + "', '"; insertSQL += TextBox10.Text + "', '"; insertSQL += TextBox30.Text + "', '"; insertSQL += TextBox31.Text + "', '"; insertSQL += TextBox32.Text + "', '"; insertSQL += TextBox33.Text + "', '"; insertSQL += TextBox34.Text + "', '"; insertSQL += TextBox35.Text + "', '"; insertSQL += TextBox36.Text + "', '"; insertSQL += TextBox18.Text

        P Offline
        P Offline
        Paramhans Dubey
        wrote on last edited by
        #3

        what is the error message?

        S 1 Reply Last reply
        0
        • S sumanmks

          hi i am very new to asp.net. It may be the simplest problem to u. but for me it is a bit difficult. I have written a code for inserting the values in the SQLEXPRESS in C#.but not able to insert it. Can Any one help me out. the code is as follows: protected void Button1_Click1(object sender, EventArgs e) { SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = @"Data Source=localhost\SQLEXPRESS;" + "Initial Catalog=testdata;Integrated Security=SSPI"; try { myConnection.Open(); Label1.Text = "<b>Server Version:</b> " + myConnection.ServerVersion; Label1.Text += "<br /><b>Connection Is:</b> " + myConnection.State.ToString(); string insertSQL; insertSQL = "INSERT INTO jobseekerinfo ("; insertSQL += "firstname, middlename, lastname, "; insertSQL += "dob, address, city, state, zip, mobile, phone, engcollege, "; insertSQL += "enguniversity, engaggergate, pucollege, puuniversity, pumarks,"; insertSQL += "school, scuniversity, scmarks, totalyears, totalmonths,"; insertSQL += "workplace, job, skills"; insertSQL += "VALUES ('"; insertSQL += TextBox1.Text + "', '"; insertSQL += TextBox2.Text + "', '"; insertSQL += TextBox3.Text + "', '"; insertSQL += TextBox29.Text + "', '"; insertSQL += TextBox5.Text + "', '"; insertSQL += TextBox11.Text + "', '"; insertSQL += TextBox12.Text + "', '"; insertSQL += TextBox14.Text + "', '"; insertSQL += TextBox6.Text + "', '"; insertSQL += TextBox15.Text + "', '"; insertSQL += TextBox4.Text + "', '"; insertSQL += TextBox8.Text + "', '"; insertSQL += TextBox9.Text + "', '"; insertSQL += TextBox10.Text + "', '"; insertSQL += TextBox30.Text + "', '"; insertSQL += TextBox31.Text + "', '"; insertSQL += TextBox32.Text + "', '"; insertSQL += TextBox33.Text + "', '"; insertSQL += TextBox34.Text + "', '"; insertSQL += TextBox35.Text + "', '"; insertSQL += TextBox36.Text + "', '"; insertSQL += TextBox18.Text

          K Offline
          K Offline
          ksss_maheshece
          wrote on last edited by
          #4

          It may be a sytex error 1) Ensure ur column names r right 2) compare front end values with database datatype.:thumbsup:

          1 Reply Last reply
          0
          • S sumanmks

            hi i am very new to asp.net. It may be the simplest problem to u. but for me it is a bit difficult. I have written a code for inserting the values in the SQLEXPRESS in C#.but not able to insert it. Can Any one help me out. the code is as follows: protected void Button1_Click1(object sender, EventArgs e) { SqlConnection myConnection = new SqlConnection(); myConnection.ConnectionString = @"Data Source=localhost\SQLEXPRESS;" + "Initial Catalog=testdata;Integrated Security=SSPI"; try { myConnection.Open(); Label1.Text = "<b>Server Version:</b> " + myConnection.ServerVersion; Label1.Text += "<br /><b>Connection Is:</b> " + myConnection.State.ToString(); string insertSQL; insertSQL = "INSERT INTO jobseekerinfo ("; insertSQL += "firstname, middlename, lastname, "; insertSQL += "dob, address, city, state, zip, mobile, phone, engcollege, "; insertSQL += "enguniversity, engaggergate, pucollege, puuniversity, pumarks,"; insertSQL += "school, scuniversity, scmarks, totalyears, totalmonths,"; insertSQL += "workplace, job, skills"; insertSQL += "VALUES ('"; insertSQL += TextBox1.Text + "', '"; insertSQL += TextBox2.Text + "', '"; insertSQL += TextBox3.Text + "', '"; insertSQL += TextBox29.Text + "', '"; insertSQL += TextBox5.Text + "', '"; insertSQL += TextBox11.Text + "', '"; insertSQL += TextBox12.Text + "', '"; insertSQL += TextBox14.Text + "', '"; insertSQL += TextBox6.Text + "', '"; insertSQL += TextBox15.Text + "', '"; insertSQL += TextBox4.Text + "', '"; insertSQL += TextBox8.Text + "', '"; insertSQL += TextBox9.Text + "', '"; insertSQL += TextBox10.Text + "', '"; insertSQL += TextBox30.Text + "', '"; insertSQL += TextBox31.Text + "', '"; insertSQL += TextBox32.Text + "', '"; insertSQL += TextBox33.Text + "', '"; insertSQL += TextBox34.Text + "', '"; insertSQL += TextBox35.Text + "', '"; insertSQL += TextBox36.Text + "', '"; insertSQL += TextBox18.Text

            S Offline
            S Offline
            sashidhar
            wrote on last edited by
            #5

            try the below link http://www.codeproject.com/Messages/3218117/Re-query.aspx[^]

            sumanmks wrote:

            i am very new to asp.net.

            Try to learn Books and articles It May Help You A lot..! Try To Use Efficient Coding..!

            MyFirstArticlePublished: MenuControlSelectedItem Why Do Some People Forget To Mark as Answer .If It Helps.

            modified on Thursday, October 1, 2009 5:58 AM

            1 Reply Last reply
            0
            • P Paramhans Dubey

              what is the error message?

              S Offline
              S Offline
              sumanmks
              wrote on last edited by
              #6

              hi sir, there r no syntax errors

              G P 2 Replies Last reply
              0
              • S sumanmks

                hi sir, there r no syntax errors

                G Offline
                G Offline
                Greg Chelstowski
                wrote on last edited by
                #7

                For crying out loud man, your t-sql is totally out of whack. There might not be any syntax error in your C# project, all it sees is building a string for the most part. What is the exception caught? Did you debug it? I bet the farm though, your insert statement has been built incorrectly, because one can plainly see that looking at it. As i said, close the damn bracket and get rid of the comma, would you? Oh yeah, sorry. I hadnt noticed you're not even CATCHING the exception. Well, good luck--

                var question = (_2b || !(_2b));

                1 Reply Last reply
                0
                • S sumanmks

                  hi sir, there r no syntax errors

                  P Offline
                  P Offline
                  Paramhans Dubey
                  wrote on last edited by
                  #8

                  <code>insertSQL += "workplace, job, skills)"; insertSQL += "VALUES ('"; you missed the )

                  G 1 Reply Last reply
                  0
                  • P Paramhans Dubey

                    <code>insertSQL += "workplace, job, skills)"; insertSQL += "VALUES ('"; you missed the )

                    G Offline
                    G Offline
                    Greg Chelstowski
                    wrote on last edited by
                    #9

                    Should I use my invisibility to fight crime or for evil. Look at the first reply, Captain Obvious. And my next one. And at the end of his insertSQL+= crap, see that there's an unnecessary comma being sent along with the rest of the T-SQL. Ok, that's it.

                    var question = (_2b || !(_2b));

                    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