数据库的插入操作:ADOCommand控件,运行SQL语句插入数据到数据库,出现异常以后如何判断到底是SQL语句有问题还是连接数据库的网络有问题呢? AdoCom.CommandText := strSQl;
try
AdoCom.Execute;
except
{WillADD :Send Message to Main Interface}
{WillADD :判断为什么插入异常}
AdoCon.Close;
COMM_ConnectDatabase();
end;
try
AdoCom.Execute;
except
{WillADD :Send Message to Main Interface}
{WillADD :判断为什么插入异常}
AdoCon.Close;
COMM_ConnectDatabase();
end;
...
except
on E: Exception do showmessage(E.Message)
end;
能获得错误信息,E.Message
AdoCom.Execute;
except on EDatabaseError do
begin
AdoCon.Close;
COMM_ConnectDatabase();
end;
end;