string DelName = this.txt_DelName.Text.Trim();
string oledbStr = "delete table1 where name='" + DelName + "'"; //根据输入的name删除table1表中相应的数据
OleDbConnection myconn = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = d:
\\data1.mdb ;"); //建立连接
try
{
myconn.Open(); //打开连接
OleDbCommand cmd = new OleDbCommand(oledbStr,myconn); //建立命令
cmd.ExecuteNonQuery(); //执行命令
}
catch(Exception exp)
{
Response.Write(exp.Message); //如果出错,输出错误信息
}
finally
{
myconn.Close(); //关闭连接
}