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. First insert ignore adding records to Access

First insert ignore adding records to Access

Scheduled Pinned Locked Moved Database
game-devquestionannouncement
1 Posts 1 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
    PaleyX
    wrote on last edited by
    #1

    Using the following code the first insert is ignored so only the 'y' and 'z' rows appear in the table. The table is empty before any of the inserts. Anybody know why this is happening? Is there an easier way of getting data into a table? OleDbConnection cn = new OleDbConnection(); cn.ConnectionString = @"Provider=Microsoft.JET.OLEDB.4.0;" + @"Data Source=" + sDBPath + ";" + @"Jet OLEDB:Engine Type=5"; cn.Open(); // OleDbDataAdapter adap = new OleDbDataAdapter("SELECT * FROM Info",cn); OleDbCommand cmdInsert = new OleDbCommand(); cmdInsert.Connection = cn; cmdInsert.CommandText = @"INSERT INTO Info (InfoDesc, InfoVal) VALUES (?, ?)"; cmdInsert.Parameters.Add(new OleDbParameter("InfoDesc",OleDbType.VarWChar,50,"InfoDesc")); cmdInsert.Parameters.Add(new OleDbParameter("InfoVal",OleDbType.VarWChar,50,"InfoVal")); adap.InsertCommand = cmdInsert; DataSet ds = new DataSet(); adap.Fill(ds,"Info"); DataRow dr = null; dr = ds.Tables[0].NewRow(); dr["InfoDesc"] = "x"; dr["InfoVal"] = "x"; ds.Tables[0].Rows.Add(dr); dr = ds.Tables[0].NewRow(); dr["InfoDesc"] = "y"; dr["InfoVal"] = "y"; ds.Tables[0].Rows.Add(dr); dr = ds.Tables[0].NewRow(); dr["InfoDesc"] = "z"; dr["InfoVal"] = "z"; ds.Tables[0].Rows.Add(dr); adap.Update(ds,"Info"); ds.Dispose(); // cn.Close();> Rugby League: The Greatest Game Of All.

    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