12-DataAdapter
DataAdapter是DataSet和DataBase之间关联的桥梁,用于填充DataSet和更新DataBase的一组命令和一个数据库连接.
它包含四个与COMMAND相关的属性:
SELECTCOMMAND:
INSERTCOMMAND:
UPDATECOMMAND:
DELETECOMMAND:
例子:
String cmdText = "SELECT * FROM Users";
SqlDataAdapter da = new SqlDataAdapter(cmdText, myConnection);
da.SelectCommand.CommandType = CommandType.Text;
myConnection.Open();
DataSet ds = new DataSet();
da.Fill(ds);
myConnection.Close();
myDataGrid.DataSource = ds;
myDataGrid.DataBind();
Fill方法的重载.
public int Fill( DataTable)
public int Fill(DataSet)
public int Fill(DataSet, strTabName)
public int Fill(DataSet, intStartRow, intEndRow, strTabName)
Update()
public int Update(DataRow[])
public override int Update(DataSet)
public int Update(DataTable)
protected virtual int Update(DataRow[], DataTableMapping)
public int Update(DataSet, strTabName)
它包含四个与COMMAND相关的属性:
SELECTCOMMAND:
INSERTCOMMAND:
UPDATECOMMAND:
DELETECOMMAND:
例子:
String cmdText = "SELECT * FROM Users";
SqlDataAdapter da = new SqlDataAdapter(cmdText, myConnection);
da.SelectCommand.CommandType = CommandType.Text;
myConnection.Open();
DataSet ds = new DataSet();
da.Fill(ds);
myConnection.Close();
myDataGrid.DataSource = ds;
myDataGrid.DataBind();
Fill方法的重载.
public int Fill( DataTable)
public int Fill(DataSet)
public int Fill(DataSet, strTabName)
public int Fill(DataSet, intStartRow, intEndRow, strTabName)
Update()
public int Update(DataRow[])
public override int Update(DataSet)
public int Update(DataTable)
protected virtual int Update(DataRow[], DataTableMapping)
public int Update(DataSet, strTabName)
_____________________________________________________________________________________
COPYRIGHT©2008,HTTP://ZEROBUG.CNBLOGS.COM .ALL RIGHTS RESERVED.
COPYRIGHT©2008,HTTP://ZEROBUG.CNBLOGS.COM .ALL RIGHTS RESERVED.