try
{
string strCon = @" Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = .\\tongxunlu.mdb " ;
OleDbConnection myConn = new OleDbConnection ( strCon ) ;
myConn.Open ( ) ;
string strDele = "DELETE FROM myfriend WHERE xingming= '" + txtName.Text+"'" ;
OleDbCommand myCommand = new OleDbCommand ( strDele , myConn ) ;
//从数据库中删除指定记录
myCommand.ExecuteNonQuery ( ) ;
//从DataSet中删除指定记录信息
OleDataAdapter dt = new OleDataAdapter();
DataSet myDataSet =new DataSet();
myDataSet.Tables[0].Rows [ myBind.Position ].Delete ( ) ;
myDataSet.Tables[0].AcceptChanges ( ) ;
MessageBox.Show("删除成功");
myConn.Close ( ) ;
}
catch(OleDbException ex)
{
MessageBox.Show(ex.ToString());
}
catch(NullReferenceException exx)
{
MessageBox.Show(exx.ToString());
}
}
这是我写的代码 不过不知道哪出错了 希望大大门帮我改下