W
wo315
Unregistered / Unconfirmed
GUEST, unregistred user!
无论我怎样试总是出错。不知道是SQL语言的问题,还是其他的原因。
procedure TForm1.BtnPostClick(Sender: TObject);
var
// i:integer;
ValueExist:boolean;
tempquery: TADOQuery;
begin
if (Edit1.text <>'') and (Edit2.Text <>'') and (Edit3.Text <>'') and (Edit4.Text <> '')
and (Edit5.Text <>'') {and(Edit6.text <>'') and (Edit7.Text <>'') and (Edit8.Text <>'') and (Edit9.Text <> '')
and (Edit10.Text <>'') and(Edit11.text <>'') and (Edit12.Text <>'') and (Edit13.Text <>'') and (Edit14.Text <> '')
and (Edit15.Text <>'') and(Edit16.text <>'') and (Edit17.Text <>'') and (Edit18.Text <>'') and (Edit19.Text <> '')
and (Edit20.Text <>'') and(Edit21.text <>'') and (Edit22.Text <>'') and (Edit23.Text <>'')} then
begin
ValueExist:=false;
if ADODataSet1.State= dsInsert then
begin
// StrToInt(Edit1.Text);
StrToInt(Edit2.Text);
StrToInt(Edit3.Text);
StrToInt(Edit4.Text);
StrToInt(Edit5.Text);
{ StrToInt(Edit6.Text);
StrToInt(Edit7.Text);
StrToInt(Edit8.Text);
StrToInt(Edit9.Text);
StrToInt(Edit10.Text);
StrToInt(Edit11.Text);
StrToInt(Edit12.Text);
StrToInt(Edit12.Text);
StrToInt(Edit14.Text);
StrToInt(Edit15.Text);
StrToInt(Edit16.Text);
StrToInt(Edit17.Text);
StrToInt(Edit18.Text);
StrToInt(Edit19.Text);
StrToInt(Edit20.Text);
StrToInt(Edit21.Text);
StrToInt(Edit22.Text);
StrToInt(Edit23.Text);}
if ValueExist=false then
begin
ADODataSet1.post;
MessageDlg('添加/修改记录成功!',mtInformation,[mbok],0);
RefreshData;
end
else
begin
MessageDlg('该准则已存在,不能保存!',mtError,[mbok],0);
ADODataSet1.CancelUpdates;
end;
end
else
begin
if ValueExist=false then
begin
tempquery:= TADOQuery.Create(self);
try
with tempquery do
begin
close;
connection := ADOConnection1;
sql.Text := 'Update 里程表 set 起讫桩号='''+Edit1.Text+''' where 起讫桩号=''''''';
ExecSQL;
end;
except
MessageDlg('修改记录失败!',mtError,[mbok],0);
tempquery.Free;
exit;
end;
tempquery.Free;
MessageDlg('添加/修改记录成功!',mtInformation,[mbok],0);
RefreshData;
end
else
begin
MessageDlg('该准则已存在,不能保存!',mtError,[mbok],0);
ADODataSet1.CancelUpdates;
end;
end;
end
else
begin
MessageDlg('添加/修改内容不能为空!',mtError,[mbok],0);
ADODataSet1.CancelUpdates;
end;
Edit1.Visible := true;
Edit2.Visible := true;
Edit3.Visible := true;
Edit4.Visible := true;
Edit5.Visible := true;
{Edit6.Visible := true;
Edit7.Visible := true;
Edit8.Visible := true;
Edit9.Visible := true;
Edit10.Visible := true;
Edit11.Visible := true;
Edit12.Visible := true;
Edit13.Visible := true;
Edit14.Visible := true;
Edit15.Visible := true;
Edit16.Visible := true;
Edit17.Visible := true;
Edit18.Visible := true;
Edit19.Visible := true;
Edit20.Visible := true;
Edit21.Visible := true;
Edit22.Visible := true;
Edit23.Visible := true;}
Edit1.Text := '';
Edit2.Text := '';
Edit3.Text := '';
Edit4.Text := '';
Edit5.Text := '';
{ Edit6.Text := '';
Edit7.Text := '';
Edit8.Text := '';
Edit9.Text := '';
Edit10.Text := '';
Edit11.Text := '';
Edit12.Text := '';
Edit13.Text := '';
Edit14.Text := '';
Edit15.Text := '';
Edit16.Text := '';
Edit17.Text := '';
Edit18.Text := '';
Edit19.Text := '';
Edit20.Text := '';
Edit21.Text := '';
Edit22.Text := '';
Edit23.Text := '';}
BtnAdd.Enabled:=true;
BtnModify.Enabled:=true;
BtnPost.Enabled:=false;
BtnDel.Enabled:=true;
end;
错误是:无法插入空行。行必须至少有一个列值集。
SQL语言中的update我也不是很明白。
谢谢告诉我的人。
procedure TForm1.BtnPostClick(Sender: TObject);
var
// i:integer;
ValueExist:boolean;
tempquery: TADOQuery;
begin
if (Edit1.text <>'') and (Edit2.Text <>'') and (Edit3.Text <>'') and (Edit4.Text <> '')
and (Edit5.Text <>'') {and(Edit6.text <>'') and (Edit7.Text <>'') and (Edit8.Text <>'') and (Edit9.Text <> '')
and (Edit10.Text <>'') and(Edit11.text <>'') and (Edit12.Text <>'') and (Edit13.Text <>'') and (Edit14.Text <> '')
and (Edit15.Text <>'') and(Edit16.text <>'') and (Edit17.Text <>'') and (Edit18.Text <>'') and (Edit19.Text <> '')
and (Edit20.Text <>'') and(Edit21.text <>'') and (Edit22.Text <>'') and (Edit23.Text <>'')} then
begin
ValueExist:=false;
if ADODataSet1.State= dsInsert then
begin
// StrToInt(Edit1.Text);
StrToInt(Edit2.Text);
StrToInt(Edit3.Text);
StrToInt(Edit4.Text);
StrToInt(Edit5.Text);
{ StrToInt(Edit6.Text);
StrToInt(Edit7.Text);
StrToInt(Edit8.Text);
StrToInt(Edit9.Text);
StrToInt(Edit10.Text);
StrToInt(Edit11.Text);
StrToInt(Edit12.Text);
StrToInt(Edit12.Text);
StrToInt(Edit14.Text);
StrToInt(Edit15.Text);
StrToInt(Edit16.Text);
StrToInt(Edit17.Text);
StrToInt(Edit18.Text);
StrToInt(Edit19.Text);
StrToInt(Edit20.Text);
StrToInt(Edit21.Text);
StrToInt(Edit22.Text);
StrToInt(Edit23.Text);}
if ValueExist=false then
begin
ADODataSet1.post;
MessageDlg('添加/修改记录成功!',mtInformation,[mbok],0);
RefreshData;
end
else
begin
MessageDlg('该准则已存在,不能保存!',mtError,[mbok],0);
ADODataSet1.CancelUpdates;
end;
end
else
begin
if ValueExist=false then
begin
tempquery:= TADOQuery.Create(self);
try
with tempquery do
begin
close;
connection := ADOConnection1;
sql.Text := 'Update 里程表 set 起讫桩号='''+Edit1.Text+''' where 起讫桩号=''''''';
ExecSQL;
end;
except
MessageDlg('修改记录失败!',mtError,[mbok],0);
tempquery.Free;
exit;
end;
tempquery.Free;
MessageDlg('添加/修改记录成功!',mtInformation,[mbok],0);
RefreshData;
end
else
begin
MessageDlg('该准则已存在,不能保存!',mtError,[mbok],0);
ADODataSet1.CancelUpdates;
end;
end;
end
else
begin
MessageDlg('添加/修改内容不能为空!',mtError,[mbok],0);
ADODataSet1.CancelUpdates;
end;
Edit1.Visible := true;
Edit2.Visible := true;
Edit3.Visible := true;
Edit4.Visible := true;
Edit5.Visible := true;
{Edit6.Visible := true;
Edit7.Visible := true;
Edit8.Visible := true;
Edit9.Visible := true;
Edit10.Visible := true;
Edit11.Visible := true;
Edit12.Visible := true;
Edit13.Visible := true;
Edit14.Visible := true;
Edit15.Visible := true;
Edit16.Visible := true;
Edit17.Visible := true;
Edit18.Visible := true;
Edit19.Visible := true;
Edit20.Visible := true;
Edit21.Visible := true;
Edit22.Visible := true;
Edit23.Visible := true;}
Edit1.Text := '';
Edit2.Text := '';
Edit3.Text := '';
Edit4.Text := '';
Edit5.Text := '';
{ Edit6.Text := '';
Edit7.Text := '';
Edit8.Text := '';
Edit9.Text := '';
Edit10.Text := '';
Edit11.Text := '';
Edit12.Text := '';
Edit13.Text := '';
Edit14.Text := '';
Edit15.Text := '';
Edit16.Text := '';
Edit17.Text := '';
Edit18.Text := '';
Edit19.Text := '';
Edit20.Text := '';
Edit21.Text := '';
Edit22.Text := '';
Edit23.Text := '';}
BtnAdd.Enabled:=true;
BtnModify.Enabled:=true;
BtnPost.Enabled:=false;
BtnDel.Enabled:=true;
end;
错误是:无法插入空行。行必须至少有一个列值集。
SQL语言中的update我也不是很明白。
谢谢告诉我的人。