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. databinding textbox to a database

databinding textbox to a database

Scheduled Pinned Locked Moved Database
csharpasp-netdatabasequestionlearning
7 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.
  • L Offline
    L Offline
    laziale
    wrote on last edited by
    #1

    Hi guys, I am beginner in ASP.NET Programming. I want to know one thing, what is think really simple. I have a textbox and a button, and I would like the text what will be entered in the textbox to be added in the table in the database. If is possible, in C# language, cause I am using that language. Thanks ahead

    J 1 Reply Last reply
    0
    • L laziale

      Hi guys, I am beginner in ASP.NET Programming. I want to know one thing, what is think really simple. I have a textbox and a button, and I would like the text what will be entered in the textbox to be added in the table in the database. If is possible, in C# language, cause I am using that language. Thanks ahead

      J Offline
      J Offline
      Joe 2
      wrote on last edited by
      #2

      laziale wrote:

      I am beginner

      Now that you've said that, I recommend you to do some research using google.

      Give a man a fish, he'll eat for a day. Teach a man how to fish, he'll eat for lifetime. Pradeep Joe

      L 1 Reply Last reply
      0
      • J Joe 2

        laziale wrote:

        I am beginner

        Now that you've said that, I recommend you to do some research using google.

        Give a man a fish, he'll eat for a day. Teach a man how to fish, he'll eat for lifetime. Pradeep Joe

        L Offline
        L Offline
        laziale
        wrote on last edited by
        #3

        I did it, but the results there are not really helping to me.

        Y 1 Reply Last reply
        0
        • L laziale

          I did it, but the results there are not really helping to me.

          Y Offline
          Y Offline
          yogesh_kumar_agarwal
          wrote on last edited by
          #4

          use the following : - 1. Import the SqlClient namespace 2. Create the object of SQL Connect to bind with SQLServer SQLConnection con=new SQLConnection("Initial Catelog=test;Data Source=.;user id=sa;password=pwd"); here Data Source is the computer name on which the database in created Initial Catelog is the database name available on the server user id is the user id for database as on password 3. Now create the command object to give the sql command to the sever SQLCommand cmd=new SQLCommand(sqlstr,con); here con is the object for connection and sqlstr is the query to execute like in our case it is "insert into tbltest values ('" + txtname.text + "')" 4. Now Execute the command using cmd object cmd.ExecuteNonQuery(); Remember to open the connection using con.Open() before xecution of Query. If fell any trouble then plz reply With Regards Yogesh Agarwal

          L 1 Reply Last reply
          0
          • Y yogesh_kumar_agarwal

            use the following : - 1. Import the SqlClient namespace 2. Create the object of SQL Connect to bind with SQLServer SQLConnection con=new SQLConnection("Initial Catelog=test;Data Source=.;user id=sa;password=pwd"); here Data Source is the computer name on which the database in created Initial Catelog is the database name available on the server user id is the user id for database as on password 3. Now create the command object to give the sql command to the sever SQLCommand cmd=new SQLCommand(sqlstr,con); here con is the object for connection and sqlstr is the query to execute like in our case it is "insert into tbltest values ('" + txtname.text + "')" 4. Now Execute the command using cmd object cmd.ExecuteNonQuery(); Remember to open the connection using con.Open() before xecution of Query. If fell any trouble then plz reply With Regards Yogesh Agarwal

            L Offline
            L Offline
            laziale
            wrote on last edited by
            #5

            and what should I write for the button onclick action?? Btw thx for the previous reply, I appreciated, and it really help me. and I get one error for connection con.open: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

            Y 1 Reply Last reply
            0
            • L laziale

              and what should I write for the button onclick action?? Btw thx for the previous reply, I appreciated, and it really help me. and I get one error for connection con.open: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

              Y Offline
              Y Offline
              yogesh_kumar_agarwal
              wrote on last edited by
              #6

              The code i gave could be written on button click event and if you receive this message then check you connection string is it correct?? Yogesh Agarwal

              L 1 Reply Last reply
              0
              • Y yogesh_kumar_agarwal

                The code i gave could be written on button click event and if you receive this message then check you connection string is it correct?? Yogesh Agarwal

                L Offline
                L Offline
                laziale
                wrote on last edited by
                #7

                Thx man, it works now for me, I learn something new today. Have a nice time till the next chat and best wishes

                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