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. Update an item in MySQL with VS2003

Update an item in MySQL with VS2003

Scheduled Pinned Locked Moved Database
databasemysqlarchitecturetutorialquestion
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.
  • K Offline
    K Offline
    kd8341
    wrote on last edited by
    #1

    I try to use ODBC to update an item in MySQL table "my_status", but it doesn't work. Seems the data can be loaded to the dataset, but how to write it back to the data sourse? Is there anybody can give me some ideas or samples on how to do this? Here is my code: /////connect to the database with DataSet String* strSql = "SELECT * FROM my_status"; OdbcDataAdapter* da = new OdbcDataAdapter(strSql,MYSQLCONN); OdbcCommandBuilder* custCB = new OdbcCommandBuilder(da); OdbcCommand* cmd; cmd = new OdbcCommand("Select * from my_status", MyConn); da->SelectCommand = cmd; DataSet* wrbtDS = new DataSet(); da->Fill(wrbtDS, "my_status"); DataRow* cRow = wrbtDS->Tables->Item["my_status"]->Rows->Item[0]; //// load the image into the dataset String * FILE_NAME = "Solid.jpg"; // for inserting a image file FileStream* fs = new FileStream(FILE_NAME, FileMode::Open, FileAccess::Read); Int16 imglen = (int)fs->Length; Byte buffer[] = new Byte[imglen]; fs->Read(buffer,0,buffer->Length); cRow->Item["image"] = buffer; /* until here the item["image"] is changed and shows in DataSet, but how to update the data source with this updated DataSet??????? The following code doesn't work and how to figure it out?*/ wrbtDS->Tables->Item["my_status"]->Rows->Item[0]->AcceptChanges(); da->Update(wrbtDS, "my_status"); Thanks a lot! Kevin

    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