Use SqlDataAdapter to update database, but SqlCommandBuilder required

            SqlDataAdapter da = new SqlDataAdapter();
           SqlCommand cmd = new SqlCommand("select * from t_upload", conn);
           da.SelectCommand = cmd;
         
           SqlCommandBuilder cb = new SqlCommandBuilder(da);

           DataSet ds = new DataSet();
           da.Fill(ds, "upload");
           DataRow newrow = ds.Tables[0].NewRow();
           newrow["filesize"] = filesize;
           newrow["filename"] = filename;
           newrow["filecontent"] = content;
           ds.Tables[0].Rows.Add(newrow);
           fs.Close();
           da.Update(ds, "upload");
           conn.Close();

posted on 2008-01-04 21:44  飞天舞者  阅读(182)  评论(0编辑  收藏  举报

导航

For more information about me, feel free email to me winston.he@hotmail.com