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. DataAdapter.Update Problem

DataAdapter.Update Problem

Scheduled Pinned Locked Moved Database
databasecsharphelptutorial
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.
  • M Offline
    M Offline
    MohammadAmiry
    wrote on last edited by
    #1

    Hi I use the following code to add a row to my database using ADO.NET in VB.NET:

    Dim strConnstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\DB.mdb"
            Dim Sql As String = String.Format("INSERT INTO Employee(FName,LName,Salary) VALUES('{0}','{1}',{2})", txtFirstName.Text, txtLastName.Text, txtSalary2.Text)
    
            Dim Conn As New OleDbConnection(strConnstring)
            Dim Comm As New OleDbCommand(Sql, Conn)
            Dim DA As New OleDbDataAdapter(Comm)
            Dim DS As New DataSet
            Conn.Open()
            Comm.ExecuteNonQuery()
            Conn.Close()
    

    Everything looks fine, the datagrid which shows Employee table, shows that the item is added. But DataAdapter does not update the dataset! I noticed that when I add a row by this method, the State of the row is not set to Added, like when I use Rows.Add (which works just fine!) I need to do this using this SQL command, but how to update the database also? (I again notice that myDataSet.GetChanged is null!)

    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