小弟写了一段代码,如下:
procedure Tuserinfofrm.BitBtn2Click(Sender: TObject);
begin
if RadioButton1.Checked then
begin
If not checkmodified(Edit1.Text,Edit2.Text,usertype.ItemIndex) then exit;
Quser.SQL.Add('update user_info set 学生证号=:str_no,等级=:class where 姓名=:name');
Quser.ParamByName('name').AsString:=Edit1.Text;
Quser.ParamByName('str_no').AsString:=Edit2.Text;
Quser.ParamByName('class').AsString:=inttostr(usertype.ItemIndex);
Quser.ExecSQL;
Messagedlg('修改成功',mtinformation,[mbYes],0);
end;
if RadioButton2.Checked then
begin
if trim(Edit1.Text)='' then
begin
showmessage('用户名不能为空!');
exit;
end;
if checkuserexit(Edit1.Text) then
begin
showmessage('该用户已经存在,请重新输入用户名!');
exit;
end;
Quser.SQL.Add('insert into user_info(姓名,学生证号,等级) values(:name,:str_no,class)');
Quser.ParamByName('name').AsString:=Edit1.Text;
Quser.ParamByName('str_no').AsString:=Edit2.Text;
Quser.ParamByName('class').AsString:=inttostr(usertype.ItemIndex);
showmessage('1');
Quser.ExecSQL;
Quser.Post;
Messagedlg('添加用户成功!',mtinformation,[mbYes],0);
end;
listuserinfo;
Quser.Close;
Quser.Free;
end;
但在运行时老出现“probject probject1.exe raised exception class EAccessViolation wity message 'Access violation at address 004B2220 in module'project1.ext'.read of address 00000248'.process stopped.use step or run to contion”.错误提示,不知是什么原因,请各位大侠们帮帮忙!!!谢谢了!!!
上面用到的函数没有问题,错误提示就出在insert 语句和update语句上。
procedure Tuserinfofrm.BitBtn2Click(Sender: TObject);
begin
if RadioButton1.Checked then
begin
If not checkmodified(Edit1.Text,Edit2.Text,usertype.ItemIndex) then exit;
Quser.SQL.Add('update user_info set 学生证号=:str_no,等级=:class where 姓名=:name');
Quser.ParamByName('name').AsString:=Edit1.Text;
Quser.ParamByName('str_no').AsString:=Edit2.Text;
Quser.ParamByName('class').AsString:=inttostr(usertype.ItemIndex);
Quser.ExecSQL;
Messagedlg('修改成功',mtinformation,[mbYes],0);
end;
if RadioButton2.Checked then
begin
if trim(Edit1.Text)='' then
begin
showmessage('用户名不能为空!');
exit;
end;
if checkuserexit(Edit1.Text) then
begin
showmessage('该用户已经存在,请重新输入用户名!');
exit;
end;
Quser.SQL.Add('insert into user_info(姓名,学生证号,等级) values(:name,:str_no,class)');
Quser.ParamByName('name').AsString:=Edit1.Text;
Quser.ParamByName('str_no').AsString:=Edit2.Text;
Quser.ParamByName('class').AsString:=inttostr(usertype.ItemIndex);
showmessage('1');
Quser.ExecSQL;
Quser.Post;
Messagedlg('添加用户成功!',mtinformation,[mbYes],0);
end;
listuserinfo;
Quser.Close;
Quser.Free;
end;
但在运行时老出现“probject probject1.exe raised exception class EAccessViolation wity message 'Access violation at address 004B2220 in module'project1.ext'.read of address 00000248'.process stopped.use step or run to contion”.错误提示,不知是什么原因,请各位大侠们帮帮忙!!!谢谢了!!!
上面用到的函数没有问题,错误提示就出在insert 语句和update语句上。
解决方案 »
- 超难问题 !!!!! 如何 将 "内存流" 转成 "英文字符"???? 然后怎样把这些 "英文字符" 转 "内存流" ???????????? 急!!!!
- PrintDBGridEh如何设置纸张大小,如何设置标题字体大小?
- 急呀!苦呀!请各位大侠们帮帮忙!!!!!!
- 怎么读取dfm文件的信息!??
- 问一个目录中查找文件的问题????
- 每人1000分,求DelphiX的开发资料!!!
- 表格支持拖动行列、单元格斜线,自定义换肤??
- 各位Delphi高手,在下是学习Delphi的新手,今后希望多多向你们讨教!!!
- ACCESS中的外联接:FROM jibeng left join diaochu on jibeng.档案编号=diaochu.档案编号 left join diaoru on jibeng.档案编号=diaoru.档案编号 为什么不行?//准程序员
- 怎么将一张位图反色显示,就是底片的那种效果
- TdxDBMaskEdit如何在Enable:=False;時改變背景顏色?
- 怎样判断表已经存在?
Quser.SQL.clear;//加上这两句
Quser.SQL.add........
begin
if RadioButton1.Checked then
begin
If not checkmodified(Edit1.Text,Edit2.Text,usertype.ItemIndex) then exit;
Quser.close;
Quser.SQL.clear;//加上这两句
Quser.SQL.Add('update user_info set 学生证号=:str_no,等级=:class where 姓名=:name');
Quser.ParamByName('name').AsString:=Edit1.Text;
Quser.ParamByName('str_no').AsString:=Edit2.Text;
Quser.ParamByName('class').AsString:=inttostr(usertype.ItemIndex);
Quser.ExecSQL;
Messagedlg('修改成功',mtinformation,[mbYes],0);
end;
if RadioButton2.Checked then
begin
if trim(Edit1.Text)='' then
begin
showmessage('用户名不能为空!');
exit;
end;
if checkuserexit(Edit1.Text) then
begin
showmessage('该用户已经存在,请重新输入用户名!');
exit;
end;
Quser.close;
Quser.SQL.clear;//加上这两句
Quser.SQL.Add('insert into user_info(姓名,学生证号,等级) values(:name,:str_no,class)');
Quser.ParamByName('name').AsString:=Edit1.Text;
Quser.ParamByName('str_no').AsString:=Edit2.Text;
Quser.ParamByName('class').AsString:=inttostr(usertype.ItemIndex);
showmessage('1');
Quser.ExecSQL;
//Quser.Post;去掉这一句
Messagedlg('添加用户成功!',mtinformation,[mbYes],0);
end;
listuserinfo;
//Quser.Close;
//Quser.Free;如果你的Quser不是动态生成的,这两句也应该去掉
end;