unit login;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, bsSkinData, BusinessSkinForm, StdCtrls, bsSkinCtrls, Mask,
bsSkinBoxCtrls, ExtCtrls, bsMessages;type
Tlogin_form = class(TForm)
bsBusinessSkinForm1: TbsBusinessSkinForm;
bsSkinData1: TbsSkinData;
bsStoredSkin1: TbsStoredSkin;
bsSkinLabel1: TbsSkinLabel;
bsSkinEdit1: TbsSkinEdit;
bsSkinLabel2: TbsSkinLabel;
bsSkinPasswordEdit1: TbsSkinPasswordEdit;
bsSkinComboBox1: TbsSkinComboBox;
bsSkinLabel3: TbsSkinLabel;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
bsSkinMessage1: TbsSkinMessage;
procedure bsSkinButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
login_form: Tlogin_form;implementationuses dm, main;{$R *.dfm}procedure Tlogin_form.bsSkinButton1Click(Sender: TObject);
begin
if trim(bsskinedit1.Text) ='' then
begin
login_form.bsSkinMessage1.MessageDlg('用户名不能为空!',MTINFORMATION,[MBOK],0);
bsskinedit1.SetFocus;
exit;
end;
if trim(bsskinpasswordedit1.Text) ='' then
begin
login_form.bsSkinMessage1.MessageDlg('密码不能为空!',MTINFORMATION,[MBOK],0);
bsskinpasswordedit1.SetFocus;
exit;
end;
if trim(bsskincombobox1.Text) ='' then
begin
login_form.bsSkinMessage1.MessageDlg('请选择所在部门!',mtinformation,[mbok],0);
bsskincombobox1.SetFocus;
exit;
end;
dm_form.login_adoquery.close;
dm_form.login_adoquery.SQL.Clear;
dm_form.login_adoquery.SQL.Add('select * from user where username ='''+bsskinedit1.Text+'''');
dm_form.login_adoquery.Open;
if dm_form.login_adoquery.Eof then
begin
login_form.bsSkinMessage1.MessageDlg('用户名不存在,请重新输入!',mtinformation,[mbok],0);
bsskinedit1.Clear;
bsskinpasswordedit1.Clear;
bsskinedit1.SetFocus;
exit;
end;
if dm_form.login_adoquery.FieldByName('password').AsString <>bsskinpasswordedit1.Text then
begin
login_form.bsSkinMessage1.MessageDlg('密码错误,请重新输入!',mtinformation,[mbok],0);
bsskinpasswordedit1.Clear;
bsskinpasswordedit1.SetFocus;
exit;
end;
login_form.Hide;
main_form.show;
end;end.真是郁闷,检查了好几遍,真的是不知道错在哪里了?老是提示USER附近有语法错误,救救我吧...
错误是: project plan.exe raised exception class EOleException with message'在关键字'user'附近有语法错误。'.
当我点完该提示框的ok按钮后,又会自动弹出一个bsskinctrls.PAS的单元文件出来,我在想,是不是我用的bsf皮肤控件有问题呢?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, bsSkinData, BusinessSkinForm, StdCtrls, bsSkinCtrls, Mask,
bsSkinBoxCtrls, ExtCtrls, bsMessages;type
Tlogin_form = class(TForm)
bsBusinessSkinForm1: TbsBusinessSkinForm;
bsSkinData1: TbsSkinData;
bsStoredSkin1: TbsStoredSkin;
bsSkinLabel1: TbsSkinLabel;
bsSkinEdit1: TbsSkinEdit;
bsSkinLabel2: TbsSkinLabel;
bsSkinPasswordEdit1: TbsSkinPasswordEdit;
bsSkinComboBox1: TbsSkinComboBox;
bsSkinLabel3: TbsSkinLabel;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
bsSkinMessage1: TbsSkinMessage;
procedure bsSkinButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
login_form: Tlogin_form;implementationuses dm, main;{$R *.dfm}procedure Tlogin_form.bsSkinButton1Click(Sender: TObject);
begin
if trim(bsskinedit1.Text) ='' then
begin
login_form.bsSkinMessage1.MessageDlg('用户名不能为空!',MTINFORMATION,[MBOK],0);
bsskinedit1.SetFocus;
exit;
end;
if trim(bsskinpasswordedit1.Text) ='' then
begin
login_form.bsSkinMessage1.MessageDlg('密码不能为空!',MTINFORMATION,[MBOK],0);
bsskinpasswordedit1.SetFocus;
exit;
end;
if trim(bsskincombobox1.Text) ='' then
begin
login_form.bsSkinMessage1.MessageDlg('请选择所在部门!',mtinformation,[mbok],0);
bsskincombobox1.SetFocus;
exit;
end;
dm_form.login_adoquery.close;
dm_form.login_adoquery.SQL.Clear;
dm_form.login_adoquery.SQL.Add('select * from user where username ='''+bsskinedit1.Text+'''');
dm_form.login_adoquery.Open;
if dm_form.login_adoquery.Eof then
begin
login_form.bsSkinMessage1.MessageDlg('用户名不存在,请重新输入!',mtinformation,[mbok],0);
bsskinedit1.Clear;
bsskinpasswordedit1.Clear;
bsskinedit1.SetFocus;
exit;
end;
if dm_form.login_adoquery.FieldByName('password').AsString <>bsskinpasswordedit1.Text then
begin
login_form.bsSkinMessage1.MessageDlg('密码错误,请重新输入!',mtinformation,[mbok],0);
bsskinpasswordedit1.Clear;
bsskinpasswordedit1.SetFocus;
exit;
end;
login_form.Hide;
main_form.show;
end;end.真是郁闷,检查了好几遍,真的是不知道错在哪里了?老是提示USER附近有语法错误,救救我吧...
错误是: project plan.exe raised exception class EOleException with message'在关键字'user'附近有语法错误。'.
当我点完该提示框的ok按钮后,又会自动弹出一个bsskinctrls.PAS的单元文件出来,我在想,是不是我用的bsf皮肤控件有问题呢?
解决方案 »
- if 语句的多条件问题
- 实习试用期间做了项目可以要求拿提成嘛?
- 静音怎么做啊?
- 如何用Image控件循环显示某个目录下的图片
- 主從表用觸發器刪除出錯,請教各位大俠
- 在delphi中怎么样用sql语句。数据库是access2000,用ado连接的,单机办。
- 那位能够详细的说一下 Socket.SendBuf() 和 Socket.ReceiveBuf()
- delphi 5.0 与 delphi 6.0的兼容性问题
- 各位,有谁知道怎么在分辨率改变的时候改变控件的位置,分数送上!
- 一个程序可以分为几个project来做吗?
- 使用delphi2009开发三层数据库应用的方法
- 求RemObjects与dbExpress结合的三层系统原码!
begin
login_form.bsSkinMessage1.MessageDlg('请选择所在部门!',mtinformation,[mbok],0);
bsskincombobox1.SetFocus;
exit;
end;
这一段可以不要掉,对此问题无影响
dm_form.login_adoquery.SQL.Add('select * from user where username ='''+bsskinedit1.Text+''''); 这句:user 在sql 中是关键字,你要用它做表名的话,使用的时候用中括号 [user]
或者你换个表名...
改下试试吧
我用java编写的计算器,编译没有出错但是运行后一点击按钮,就自动退出,不明白为什么!
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
//继承JFrame类实现ActionListener接口
public class calculator extends JFrame implements ActionListener{ JFrame frame;
JButton num0,num1,num2,num3,num4,num5,num6,num7,num8,num9,Back,c;//运算按钮
JButton plusButton,minusButton,multiplyButton,divideButton,residueButton,equalButton,changeButton,dotButton,sqrtButton,reciprocalButton;
JMenu fileM;
JMenuItem exitM,helpM;
JTextField text;//状态变量
boolean clicked=true;
boolean clear=true;
int all=0;
double previous;
String fubao;
int first=1;
public calculator(){
setTitle("计算器");
setSize(300,250);
setLocation(400,400);
text=new JTextField(25);
text.setHorizontalAlignment(JTextField.LEFT);
JPanel cp1=new JPanel();
JPanel cp2=new JPanel();
JPanel cp3=new JPanel();
//
getContentPane().add(cp1,"North");
getContentPane().add(cp2,"Center");
getContentPane().add(cp3,"South");
cp1.setLayout(new GridLayout(1,1));
cp2.setLayout(new GridLayout(1,3));
cp3.setLayout(new GridLayout(5,4));
//
plusButton=new JButton("+");
minusButton=new JButton("-");
multiplyButton=new JButton("*");
divideButton=new JButton("/");
residueButton=new JButton("%");
equalButton=new JButton("=");
changeButton=new JButton("+/-");
dotButton=new JButton(".");
sqrtButton=new JButton("sqrt");
reciprocalButton=new JButton("1/x");
//
num0=new JButton("0");
num1=new JButton("1");
num2=new JButton("2");
num3=new JButton("3");
num4=new JButton("4");
num5=new JButton("5");
num6=new JButton("6");
num7=new JButton("7");
num8=new JButton("8");
num9=new JButton("9");
//
cp1.add(text);
text.setEditable(false);
text.setBackground(Color.white);
Back=new JButton("BACK");
Back.addActionListener(this);
c=new JButton("c");
c.addActionListener(this);
//
cp2.add(Back);
cp2.add(c);
//
cp3.add(num7);
num7.addActionListener(this);
cp3.add(num8);
num8.addActionListener(this); cp3.add(num9);
num9.addActionListener(this);
//*
cp3.add(divideButton);
divideButton.addActionListener(this);
cp3.add(num4);
num4.addActionListener(this); cp3.add(num5);
num5.addActionListener(this); cp3.add(num6);
num6.addActionListener(this);
//
cp3.add(multiplyButton);
multiplyButton.addActionListener(this); cp3.add(num1);
num1.addActionListener(this);
cp3.add(num2);
num2.addActionListener(this); cp3.add(num3);
num3.addActionListener(this);
cp3.add(minusButton);
minusButton.addActionListener(this);
cp3.add(num0);
num0.addActionListener(this);
cp3.add(changeButton);
changeButton.addActionListener(this);
cp3.add(changeButton);
changeButton.addActionListener(this);
cp3.add(dotButton);
dotButton.addActionListener(this);
cp3.add(plusButton);
plusButton.addActionListener(this);
cp3.add(reciprocalButton);
reciprocalButton.addActionListener(this);
cp3.add(residueButton);
residueButton.addActionListener(this);
cp3.add(sqrtButton);
sqrtButton.addActionListener(this);
cp3.add(equalButton);
equalButton.addActionListener(this);
//
JMenuBar mainMenu=new JMenuBar();
setJMenuBar(mainMenu);
JMenu editMenu=new JMenu("文件");
JMenu helpMenu=new JMenu("帮助");
helpM=new JMenuItem("关于");
//
mainMenu.add(editMenu);
mainMenu.add(helpMenu);
helpMenu.add(helpM);
helpM.addActionListener(this);
fileM=new JMenu("文件");
exitM=new JMenuItem("退出");
fileM.addActionListener(this);
exitM.addActionListener(this);
editMenu.add(fileM);
editMenu.add(exitM);
setVisible(true);
addWindowListener(new WindowDestroyer());
}
if(first==1) text.setText(" ");
first=0;
Object temp=e.getSource();
if(temp==exitM);
System.exit(0);
if(temp==helpM);
JOptionPane.showMessageDialog(null,"请查看帮助文挡","帮助",JOptionPane.INFORMATION_MESSAGE);
//退格
if(temp==Back){
String s= text.getText();
text.setText(" ");
for(int i=0;i<s.length()-1;i++){
char a=s.charAt(i);
text.setText(text.getText()+a);
}
}
//清零
if(temp==c){
text.setText("0.");
clear=true;
first=1;
}
if(temp==num0){
if(clear==false)
text.setText("");
text.setText(text.getText()+"0");
}
if(temp==num1){
if(clear==false)
text.setText("");
text.setText(text.getText()+"1");
clear=true;
}
if(temp==num2){
if(clear==false)
text.setText("");
text.setText(text.getText()+"2");
clear=true;
}
if(temp==num3){
if(clear==false)
text.setText("");
text.setText(text.getText()+"3");
clear=true;
}
if(temp==num4){
if(clear==false)
text.setText("");
text.setText(text.getText()+"4");
clear=true;
}
if(temp==num5){
if(clear==false)
text.setText("");
text.setText(text.getText()+"5");
clear=true;
}
if(temp==num6){
if(clear==false)
text.setText("");
text.setText(text.getText()+"6");
clear=true;
}
if(temp==num7){
if(clear==false)
text.setText("");
text.setText(text.getText()+"7");
clear=true;
}
if(temp==num8){
if(clear==false)
text.setText("");
text.setText(text.getText()+"8");
clear=true;
}
if(temp==num9){
if(clear==false)
text.setText("");
text.setText(text.getText()+"9");
clear=true;
}
//
if(temp==dotButton){
clicked=true;
for(int i=0;i<text.getText().length();i++)
if('0'==text.getText().charAt(i)){
clicked=false;
break;
}
if(clicked==true)
text.setText(text.getText()+".");
}
try{
if(temp==plusButton){
previous=Double.parseDouble(text.getText());
fubao="+";
clear=false;
}
if(temp==minusButton){
previous=Double.parseDouble(text.getText());
fubao="-";
clear=false;
}
if(temp==multiplyButton){
previous=Double.parseDouble(text.getText());
fubao="*";
clear=false;
}
if(temp==divideButton){
previous=Double.parseDouble(text.getText());
fubao="/";
clear=false;
}
if(temp==equalButton){
double next=Double.parseDouble(text.getText());
text.setText("");
if(fubao=="+")
text.setText(previous+next+"");
if(fubao=="-")
text.setText(previous-next+"");
if(fubao=="*")
text.setText(previous*next+"");
if(fubao=="/")
if(next==0)text.setText("除数不能为零");
else
text.setText(previous/next+"");
if(fubao=="%")
text.setText(previous%next+"");
clear=false; }
if(temp==sqrtButton){
String s=text.getText();
if(s.charAt(0)=='-')
text.setText("负数不能开平方根");
else
text.setText(Double.toString(java.lang.Math.sqrt(Double.parseDouble(text.getText()))));
clear=false;
}
if(temp==reciprocalButton){
if(text.getText().charAt(0)=='0'&&text.getText().length()==1)
text.setText("除数不能为零");
else{
boolean isDec=true;
int i,j,k;
String s=Double.toString(1/Double.parseDouble(text.getText()));
for(i=0;i<s.length();i++);
if(s.charAt(i)=='.')
//
for(j=i+1;j<s.length();j++)
if(s.charAt(j)!='0'){
isDec=false;
break;
}
if(isDec==true){
String stemp="";
for(k=0;k<i;k++);
text.setText(stemp);
}
else
text.setText(s);
}
clear=false;
}
if(temp==residueButton){
previous=Double.parseDouble(text.getText());
fubao="%";
clear=false;
}
if(temp==changeButton){
boolean isNumber=true;
String s=text.getText();
for(int i=0;i<s.length();i++)
if(!(s.charAt(i)>='0'&&s.charAt(i)<='9'||s.charAt(i)=='.'||s.charAt(i)=='-')){
isNumber=false;
break;
}
if(isNumber==true){
if(s.charAt(0)=='-'){
text.setText("");
for(int i=1;i<s.length();i++){
char a=s.charAt(i);
text.setText(text.getText()+a);
}
}
else
text.setText('-'+s);
}
}
}
catch (Exception e3){
text.setText("there is wrong");
clear=false;
}
}
//
class WindowDestroyer extends WindowAdapter{
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
//
public static void main(String arg[]){
JFrame.setDefaultLookAndFeelDecorated(true);
calculator cal=new calculator();
}
}