帮我看看为什么会出现语法错误呢,我是刚上来的没有太多的分,希望大家谅解 ( 积分: 20 )

  • 主题发起人 主题发起人 fyhxf
  • 开始时间 开始时间
F

fyhxf

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TuserForm.fBitBtnClick(Sender: TObject);
var
strsql:string;
begin
strsql:='BEGGIN TRAN sp_addlogin '''+edit1.text+''','''+edit2.text+''','''+combobox1.text+''',,@encryptopt='''+combobox4.Text+'''';
strsql:=strsql+' sp_addsrvrolemember '''+ edit3.Text+''','''+combobox5.Text+'''';
strsql:=strsql+'sp_grantdbaccess '''+edit4.Text+''','''+edit5.Text+'''';
strsql:=strsql+' sp_addrolemember '''+combobox6.Text+''','''+edit6.Text+''' COMMIT TRAN';
//strsql:='sp_addlogin '''+edit1.text+''','''+edit2.text+''','''+combobox1.text+''',@encryptopt='''+combobox4.text+'''';
if ((edit1.text=edit3.text) and (edit3.text=Edit4.text)) then
begin
DataModule1.ADOQuery2.Close;
DataModule1.ADOQuery2.SQL.Clear;
DataModule1.ADOQuery2.SQL.Add(strsql);
DataModule1.ADOQuery2.ExecSQL;
end
else
showmessage('请正确输入登录帐号');
end;

procedure TuserForm.FormShow(Sender: TObject);

begin
pagecontrol1.Pages[0].Show;
ubitbtn.Enabled :=false;
fbitbtn.Enabled :=false;
try
DataModule1.adoquery1.Close ;
DataModule1.adoquery1.SQL.Clear;
DataModule1.adoquery1.SQL.Add('select name from sysdatabases');
DataModule1.adoquery1.Open;
ComboBox1.Clear;
ComboBox1.Items.Add('所有的数据库');
while not DataModule1.ADOQuery1.Eof do
begin
ComboBox1.Items.Add(trim(DataModule1.adoquery1.FieldValues['name']));
DataModule1.adoquery1.Next;
end;
ComboBox1.ItemIndex:=0;
finally
DataModule1.adoquery1.Close;
end;
try
DataModule1.adoquery1.Close ;
DataModule1.adoquery1.SQL.Clear;
DataModule1.adoquery1.SQL.Add('select name from syslanguages');
DataModule1.adoquery1.Open;
ComboBox2.Clear;
ComboBox2.Items.Add('所有的语言');
while not DataModule1.ADOQuery1.Eof do
begin
ComboBox2.Items.Add(trim(DataModule1.adoquery1.FieldValues['name']));
DataModule1.adoquery1.Next;
end;
ComboBox2.ItemIndex:=0;
finally
DataModule1.adoquery1.Close;
end;
try
DataModule1.adoquery1.Close ;
DataModule1.adoquery1.SQL.Clear;
DataModule1.adoquery1.SQL.Add('select name from sysusers');
DataModule1.adoquery1.Open;
ComboBox6.Clear;
ComboBox6.Items.Add('所有的数据库角色');
while not DataModule1.ADOQuery1.Eof do
begin
ComboBox6.Items.Add(trim(DataModule1.adoquery1.FieldValues['name']));
DataModule1.adoquery1.Next;
end;
ComboBox6.ItemIndex:=0;
finally
DataModule1.adoquery1.Close;
end;
end;
procedure TupuserForm.Button3Click(Sender: TObject);
begin
if combobox1.text='服务器用户' then
begin
DataModule1.ADOQuery2.Close;
DataModule1.ADOQuery2.SQL.Clear;
DataModule1.ADOQuery2.SQL.Add('sp_droplogin '''+combobox4.text+'''');
DataModule1.ADOQuery2.Open;
DataModule1.ADOQuery2.ExecSQL;
end
else if combobox1.text='数据库用户' then
begin
DataModule1.ADOQuery2.Close;
DataModule1.ADOQuery2.SQL.Clear;
DataModule1.ADOQuery2.SQL.Add('sp_revokedbaccess '''+combobox4.text+'''');
DataModule1.ADOQuery2.Open;
DataModule1.ADOQuery2.ExecSQL;
end
else if combobox1.text='服务器角色' then
begin
DataModule1.ADOQuery2.Close;
DataModule1.ADOQuery2.SQL.Clear;
DataModule1.ADOQuery2.SQL.Add('sp_dropsrvrrolemember '''+combobox4.text+'''');
DataModule1.ADOQuery2.Open;
DataModule1.ADOQuery2.ExecSQL;
end
else
begin
DataModule1.adoquery1.Close ;
DataModule1.adoquery1.SQL.Clear;
DataModule1.adoquery1.SQL.Add('sp_droprole '''+combobox4.text+'''');
DataModule1.adoquery1.Open;
DataModule1.ADOQuery2.ExecSQL;
end;
end;
好象是参数不怎么对,请帮帮我吧
 
procedure TuserForm.fBitBtnClick(Sender: TObject);
var
strsql:string;
begin
strsql:='BEGGIN TRAN sp_addlogin '''+edit1.text+''','''+edit2.text+''','''+combobox1.text+''',,@encryptopt='''+combobox4.Text+'''';
strsql:=strsql+' sp_addsrvrolemember '''+ edit3.Text+''','''+combobox5.Text+'''';
strsql:=strsql+'sp_grantdbaccess '''+edit4.Text+''','''+edit5.Text+'''';
strsql:=strsql+' sp_addrolemember '''+combobox6.Text+''','''+edit6.Text+''' COMMIT TRAN';
//strsql:='sp_addlogin '''+edit1.text+''','''+edit2.text+''','''+combobox1.text+''',@encryptopt='''+combobox4.text+'''';
if ((edit1.text=edit3.text) and (edit3.text=Edit4.text)) then
begin
DataModule1.ADOQuery2.Close;
DataModule1.ADOQuery2.SQL.Clear;
DataModule1.ADOQuery2.SQL.Add(strsql);
DataModule1.ADOQuery2.ExecSQL;
end
else
showmessage('请正确输入登录帐号');
end;

procedure TuserForm.FormShow(Sender: TObject);

begin
pagecontrol1.Pages[0].Show;
ubitbtn.Enabled :=false;
fbitbtn.Enabled :=false;
try
DataModule1.adoquery1.Close ;
DataModule1.adoquery1.SQL.Clear;
DataModule1.adoquery1.SQL.Add('select name from sysdatabases');
DataModule1.adoquery1.Open;
ComboBox1.Clear;
ComboBox1.Items.Add('所有的数据库');
while not DataModule1.ADOQuery1.Eof do
begin
ComboBox1.Items.Add(trim(DataModule1.adoquery1.FieldValues['name']));
DataModule1.adoquery1.Next;
end;
ComboBox1.ItemIndex:=0;
finally
DataModule1.adoquery1.Close;
end;
try
DataModule1.adoquery1.Close ;
DataModule1.adoquery1.SQL.Clear;
DataModule1.adoquery1.SQL.Add('select name from syslanguages');
DataModule1.adoquery1.Open;
ComboBox2.Clear;
ComboBox2.Items.Add('所有的语言');
while not DataModule1.ADOQuery1.Eof do
begin
ComboBox2.Items.Add(trim(DataModule1.adoquery1.FieldValues['name']));
DataModule1.adoquery1.Next;
end;
ComboBox2.ItemIndex:=0;
finally
DataModule1.adoquery1.Close;
end;
try
DataModule1.adoquery1.Close ;
DataModule1.adoquery1.SQL.Clear;
DataModule1.adoquery1.SQL.Add('select name from sysusers');
DataModule1.adoquery1.Open;
ComboBox6.Clear;
ComboBox6.Items.Add('所有的数据库角色');
while not DataModule1.ADOQuery1.Eof do
begin
ComboBox6.Items.Add(trim(DataModule1.adoquery1.FieldValues['name']));
DataModule1.adoquery1.Next;
end;
ComboBox6.ItemIndex:=0;
finally
DataModule1.adoquery1.Close;
end;
end;
procedure TupuserForm.Button3Click(Sender: TObject);
begin
if combobox1.text='服务器用户' then
begin
DataModule1.ADOQuery2.Close;
DataModule1.ADOQuery2.SQL.Clear;
DataModule1.ADOQuery2.SQL.Add('sp_droplogin '''+combobox4.text+'''');
DataModule1.ADOQuery2.Open;
DataModule1.ADOQuery2.ExecSQL;
end
else if combobox1.text='数据库用户' then
begin
DataModule1.ADOQuery2.Close;
DataModule1.ADOQuery2.SQL.Clear;
DataModule1.ADOQuery2.SQL.Add('sp_revokedbaccess '''+combobox4.text+'''');
DataModule1.ADOQuery2.Open;
DataModule1.ADOQuery2.ExecSQL;
end
else if combobox1.text='服务器角色' then
begin
DataModule1.ADOQuery2.Close;
DataModule1.ADOQuery2.SQL.Clear;
DataModule1.ADOQuery2.SQL.Add('sp_dropsrvrrolemember '''+combobox4.text+'''');
DataModule1.ADOQuery2.Open;
DataModule1.ADOQuery2.ExecSQL;
end
else
begin
DataModule1.adoquery1.Close ;
DataModule1.adoquery1.SQL.Clear;
DataModule1.adoquery1.SQL.Add('sp_droprole '''+combobox4.text+'''');
DataModule1.adoquery1.Open;
DataModule1.ADOQuery2.ExecSQL;
end;
end;
好象是参数不怎么对,请帮帮我吧
 
你的引号用的不对吧,可以把sql语句中的引号用#39代替或者用quotedstr(edit1.text)
 
你能不能做一个例子呀
 
请问,出错提示是什么?在那里出错的?
 
提出是无效的授说明
 
我看了你的那个程序了 首先那个了?BRGIN 好象是不对 多一个G吧, 还有就是看看你的那个ADIQUERY是不是有问题呀 ,你在调调试试吧 
 
接受答案了.
 
后退
顶部