注册 登录
编程论坛 Delphi论坛

????delphi 代码de 意思?

hyfcn 发布于 2008-11-10 09:53, 969 次点击
请各位老师、前辈帮我。 感谢回复者!
请各位老师、前辈帮我解释下这段代码。
begin
      if application.messagebox('确定要恢复数据库吗?)','提示信息', MB_OKCANCEL+MB_ICONINFORMATION) <> IDCANCEL then
      begin
          try
              ADOQ_check.ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=master';
              with ADOQ_check do
              begin
                  close;
                  sql.Clear;
                  sql.Add('select name from sysdatabases where name=:sname');
                  parameters.ParamByName('sname').value:=trim(CB_name.Text);
                  open;
              end;
          except
              showmessage('连接数据库失败,'+chr(13)+chr(13)+'请核实是否已正确安装 MS SQL Server7.0!');
              exit;
          end;


提供我学习的地址也行

[[it] 本帖最后由 hyfcn 于 2008-11-10 10:05 编辑 [/it]]
2 回复
#2
gykthh2008-11-10 11:14
begin
      if application.messagebox('确定要恢复数据库吗?)','提示信息', MB_OKCANCEL+MB_ICONINFORMATION) <> IDCANCEL then //弹出对话框 如果单击取消就不执行下面的代码
      begin
          try
              ADOQ_check.ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=master';//连接master数据库
              with ADOQ_check do //使用with语句
              begin
                  close;  关闭连
                  sql.Clear; 清空要执行的sql语句
                  sql.Add('select name from sysdatabases where name=:sname'); 添加带参数sql语句 查询数据库中存在的数据库 参数是指定要查询的数据库名称
                  parameters.ParamByName('sname').value:=trim(CB_name.Text);给参数赋值
                  open; 打开进行查询 数据库是否存在
              end;
          except
              showmessage('连接数据库失败,'+chr(13)+chr(13)+'请核实是否已正确安装 MS SQL Server7.0!');
              exit;
          end;

好像不是要恢复数据库的哦
#3
hyfcn2008-11-10 14:10
谢谢 二楼
1