生成DataAdapter的InsertCommand、UpdateCommand、DeleteCommand

OleDbCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * FROM song WHERE 1=0";

OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.FillSchema(ds, SchemaType.Source, "song");
da.Fill(ds, "song");

//生成InsertCommand
OleDbCommandBuilder cmdBuilder = new OleDbCommandBuilder(da);
da.InsertCommand = cmdBuilder.GetInsertCommand();
posted @ 2010-09-19 17:37  风中的云  阅读(730)  评论(0编辑  收藏  举报