生成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();

你可能感兴趣的:(command)