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. Add new record to database using C# [modified]

Add new record to database using C# [modified]

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabaselearning
6 Posts 2 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
    Poonam Gandash
    wrote on last edited by
    #1

    I am asp programmer now I am updating my skills and learning ASP.net. I am using VS2005. using Accessdatasource I fetched records from database. But I am not able to find method to add records to Database.

    modified on Wednesday, May 14, 2008 8:22 AM

    E 1 Reply Last reply
    0
    • P Poonam Gandash

      I am asp programmer now I am updating my skills and learning ASP.net. I am using VS2005. using Accessdatasource I fetched records from database. But I am not able to find method to add records to Database.

      modified on Wednesday, May 14, 2008 8:22 AM

      E Offline
      E Offline
      eyeseetee
      wrote on last edited by
      #2

      cant you just use an insert statement

      P 1 Reply Last reply
      0
      • E eyeseetee

        cant you just use an insert statement

        P Offline
        P Offline
        Poonam Gandash
        wrote on last edited by
        #3

        That I can use but I am confused with connections. I used to use command for setting connection in asp here I am using Access datasource. So how I will define connectionname to my query. In add_subadmin.aspx I added 3 text boxes and onbutton click a function is called in default.aspx.cs file . Having this code. DataSet dataSet1 = new DataSet(); DataRow newCustomersRow = dataSet1.Tables["subadmin"].NewRow(); newCustomersRow["name"] = subname.Text; newCustomersRow["username"] = username.Text; newCustomersRow["password"] = password.Text; dataSet1.Tables["subadmin"].Rows.Add(newCustomersRow); error says: Compiler Error Message: CS0103: The name 'subname' does not exist in the current context Source Error: Line 22: DataRow newCustomersRow = dataSet1.Tables["subadmin"].NewRow(); Line 23: newCustomersRow["name"] = subname.Text; Line 24: newCustomersRow["username"] = username.Text; Line 25: newCustomersRow["password"] = password.Text;

        E 1 Reply Last reply
        0
        • P Poonam Gandash

          That I can use but I am confused with connections. I used to use command for setting connection in asp here I am using Access datasource. So how I will define connectionname to my query. In add_subadmin.aspx I added 3 text boxes and onbutton click a function is called in default.aspx.cs file . Having this code. DataSet dataSet1 = new DataSet(); DataRow newCustomersRow = dataSet1.Tables["subadmin"].NewRow(); newCustomersRow["name"] = subname.Text; newCustomersRow["username"] = username.Text; newCustomersRow["password"] = password.Text; dataSet1.Tables["subadmin"].Rows.Add(newCustomersRow); error says: Compiler Error Message: CS0103: The name 'subname' does not exist in the current context Source Error: Line 22: DataRow newCustomersRow = dataSet1.Tables["subadmin"].NewRow(); Line 23: newCustomersRow["name"] = subname.Text; Line 24: newCustomersRow["username"] = username.Text; Line 25: newCustomersRow["password"] = password.Text;

          E Offline
          E Offline
          eyeseetee
          wrote on last edited by
          #4

          Check this out: http://www.aspfree.com/c/a/Microsoft-Access/Connecting-to-a-Microsoft-Access-database-with-ASPNET/"

          P 1 Reply Last reply
          0
          • E eyeseetee

            Check this out: http://www.aspfree.com/c/a/Microsoft-Access/Connecting-to-a-Microsoft-Access-database-with-ASPNET/"

            P Offline
            P Offline
            Poonam Gandash
            wrote on last edited by
            #5

            Thanks a lot its really good article but its in VB.net I am looking for C# :doh:

            E 1 Reply Last reply
            0
            • P Poonam Gandash

              Thanks a lot its really good article but its in VB.net I am looking for C# :doh:

              E Offline
              E Offline
              eyeseetee
              wrote on last edited by
              #6

              I'm sure there are plenty of converters out there, expecially if all you need is the connection string ;P

              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