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. how to insert data

how to insert data

Scheduled Pinned Locked Moved C#
csharpdatabasehelptutorial
2 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.
  • C Offline
    C Offline
    csanda1
    wrote on last edited by
    #1

    Hi Im doing an application in Visual C# 2005, my application can read data from my database but cant save into the database. Heres the code. What am I missing....Pliz Help!!!! private void btnSave_Click(object sender, EventArgs e) { string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source=YAC.mdb"; OleDbConnection conn = new OleDbConnection(strConnection); conn.Open(); string strCommand = "INSERT INTO ClientProfile(Name,Surname,Gender,IdNumber) Values ('" + txtName.Text + "','" + txtSurname.Text + "','" + cbxGender.Text + "','" + txtIdNumber.Text + "')"; OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.InsertCommand = new OleDbCommand(strCommand, conn); (this.yACDataSet.ClientProfile); int t1 = adapter.InsertCommand.ExecuteNonQuery(); conn.Close(); if (t1 > 0) { MessageBox.Show("added successfully!"); } csanda

    L 1 Reply Last reply
    0
    • C csanda1

      Hi Im doing an application in Visual C# 2005, my application can read data from my database but cant save into the database. Heres the code. What am I missing....Pliz Help!!!! private void btnSave_Click(object sender, EventArgs e) { string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source=YAC.mdb"; OleDbConnection conn = new OleDbConnection(strConnection); conn.Open(); string strCommand = "INSERT INTO ClientProfile(Name,Surname,Gender,IdNumber) Values ('" + txtName.Text + "','" + txtSurname.Text + "','" + cbxGender.Text + "','" + txtIdNumber.Text + "')"; OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.InsertCommand = new OleDbCommand(strCommand, conn); (this.yACDataSet.ClientProfile); int t1 = adapter.InsertCommand.ExecuteNonQuery(); conn.Close(); if (t1 > 0) { MessageBox.Show("added successfully!"); } csanda

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Welcome to CodeProject. There are a large number of C# Database Articles here follow the link[^]

      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