1. 首页 / 知识 /  正文

datagridview更新数据库(SqlDataAdapter.update的用法?

datagridview更新数据库(SqlDataAdapter.update的用法?

SqlConnectionconn=newSqlConnection("SERVER=.;UID=sa;PWD=sa;DATABASE=pubs");SqlDataAdapteradapter=newSqlDataAdapter("SELECT*FROMsales",conn);SqlCommandBuildercmdbuilder=newSqlCommandBuilder(adapter);DataSetds=newDataSet;adapter.Fill(ds);adapter.UpdateCommand=cmdbuilder.GetUpdateCommand;adapter.Update(ds,ds.Table[0].TableName);