我想在代码里指定FpSpread表格的数据源,代码如下。但是修改数据后却保存不到数据库中,这是为什么呢?
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
bind();
}
void bind()
{
String ConnStr1 = ConfigurationManager.ConnectionStrings["ConnStr1"].ConnectionString;
OleDbConnection conn = new OleDbConnection(ConnStr1);
conn.Open();
OleDbCommand cmd_s = conn.CreateCommand(),cmd_u=conn.CreateCommand();
cmd_s.CommandText = "select * from test order by ny";
//cmd_s.CommandText = "select * from test where ny=? and cl=?";
//cmd_s.Parameters.Add("@ny_s", OleDbType.VarChar, 2, "ny").Value = "02";
//cmd_s.Parameters.Add("@ny_s", OleDbType.Decimal, 10, "cl").Value = 11;
cmd_u.CommandText = "update test set cl=? where ny=?";
cmd_u.Parameters.Add("@cl_u", OleDbType.Decimal, 10, "cl");
cmd_u.Parameters.Add("@ny_u", OleDbType.VarChar, 2, "ny");
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd_s;
da.UpdateCommand = cmd_u;
DataSet ds = new DataSet();
da.Fill(ds);
FpSpread1.DataSource = ds;
FpSpread1.DataBind();
cmd_s.Dispose();
cmd_u.Dispose();
conn.Close();
conn.Dispose();
} |
|