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. General Programming
  3. C#
  4. inserting data

inserting data

Scheduled Pinned Locked Moved C#
helpdatabase
8 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
    sandy_r
    wrote on last edited by
    #1

    hello, I am trying to insert data into a database.My code gives no error. But the values are not inserted into database. Please help...can anyone send a sample code

    M N V 3 Replies Last reply
    0
    • S sandy_r

      hello, I am trying to insert data into a database.My code gives no error. But the values are not inserted into database. Please help...can anyone send a sample code

      M Offline
      M Offline
      M K BASHER
      wrote on last edited by
      #2

      Could u show ur code? Is there any error in database connection?

      1 Reply Last reply
      0
      • S sandy_r

        hello, I am trying to insert data into a database.My code gives no error. But the values are not inserted into database. Please help...can anyone send a sample code

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

        Your question is not explaining anything about what you did. Have you put breakpoints and stepped into the code ?

        All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

        S 1 Reply Last reply
        0
        • S sandy_r

          hello, I am trying to insert data into a database.My code gives no error. But the values are not inserted into database. Please help...can anyone send a sample code

          V Offline
          V Offline
          varun_mca_ju 0
          wrote on last edited by
          #4

          are you trying to insert data from textBox or other controls? are you using Oracle or SQl ?...plz. give some details....

          S 1 Reply Last reply
          0
          • V varun_mca_ju 0

            are you trying to insert data from textBox or other controls? are you using Oracle or SQl ?...plz. give some details....

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

            I am trying to insert from textbox.I am using SQL

            A V 2 Replies Last reply
            0
            • N N a v a n e e t h

              Your question is not explaining anything about what you did. Have you put breakpoints and stepped into the code ?

              All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

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

              No..Please tell how to go about

              1 Reply Last reply
              0
              • S sandy_r

                I am trying to insert from textbox.I am using SQL

                A Offline
                A Offline
                Ahsan225
                wrote on last edited by
                #7

                use a breakpoint to see if the text box value is parsed properly in the query. also, check the single and double quotes. they need to be in a proper sequence for the value to be fetched.

                1 Reply Last reply
                0
                • S sandy_r

                  I am trying to insert from textbox.I am using SQL

                  V Offline
                  V Offline
                  varun_mca_ju 0
                  wrote on last edited by
                  #8

                  using System.Data.SqlClient; using System.Data.OleDb; code for connecting to SQL database:- try { SqlConnection mc = new SqlConnection(Persist Security Info=False;User ID=sa;Initial Catalog=DataBase_Name;Data Source= SQL_Server_Name"); SqlDataAdapter da =new SqlDataAdapter("Select * from Table_name", mc); DataSet ds =new DataSet(); da.Fill(ds,"Table_name"); MessageBox.Show("Connection Successfull"); } catch(Exception ex) {MessageBox.Show(ex.Message); } code for inserting data from textBox:- try{ SqlCommand insertCmd=new SqlCommand("insert into Table_Name(Column_Name)values(@Variable_name)",Connection_Name); insertCmd.Parameters.Add("@Variable_Name",SqlDbType.Nchar,10); insertCmd.Parameters["@Variable_Name"].Value=textBox1.Text; insertCmd.ExecuteNonQuery(); MessageBox.Show("Records inserted successfully"); } catch(Exception ex) {MessageBox.Show(ex.Message);}

                  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