protected void Button1_Click(object sender, EventArgs e)
{
int res;
string c1 = this.TextBox1.Text.ToString();
string dw = this.DropDownList1.SelectedValue;
string commstr = @"update data set c1='" + c1 + "'" + @"where dw='" + dw + "'";
//"insert into data(c1) values('" + c1 + "')"
OleDbConnection conn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=|datadirectory|data.mdb;");
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
OleDbCommand cmd = new OleDbCommand(commstr, conn);
try
{
res = cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw new Exception("error", ex);
}
finally
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
if (res > 0)
{
Response.Write("ok");
}
else
{
Response.Write("fail");
}
}