string connstr = "Provider=Microsoft.Jet.OleDb.4.0;";
connstr += @"Data Source=D:\Merger201503016caohuan\GEARCNC.mdb";//創建連接對象
OleDbConnection tempconn = new OleDbConnection(connstr);
tempconn.Open();
OleDbDataAdapter DressingWheelDA = new OleDbDataAdapter("select * from DressingWheel order by 修整輪名稱", tempconn);
DataSet ds = new DataSet();
DressingWheelDA.Fill(ds, "DressingWheel");
OleDbCommandBuilder builder = new OleDbCommandBuilder(DressingWheelDA);
if (ds.HasChanges())
{
try
{
DressingWheelDA.Update(ds, "DressingWheel");
}
catch (Exception ex)
{
MessageBox.Show("修整輪名稱重復", "信息提示");
}
}
catch中加上
MessageBox.Show(ex.Message)看下具體錯誤信息
是不是違法了約束,或者主鍵重復之類的錯誤