在form上提示让用户输入远程服务器的计算机名或其ip地址,
数据库超级用户名称与口令
在程序中使用Ado连接数据库
动态创建AdoQuery,其SQl 语句:
create database,
create table
需要了解相应数据库的存储过程。
示例(创建表,在这之前,必须创建其数据库):
procedure CreateLogevent(var Query1:TADOQuery; var ListBox1:TListBox);
begin
{ Check whether the Table exists or not, if exists, drop it }
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('SELECT name,type FROM dbo.sysobjects '
+ 'WHERE name=
1 and type=
2');
Query1.Parameters.ParamByName('P1').Value:='Logevent';
Query1.Parameters.ParamByName('p2').Value:='U';
Query1.Open;
If Not Query1.IsEmpty then
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('drop table Logevent');
Query1.ExecSQL;
end;
{ Create the Table }
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('CREATE TABLE Logevent ( '
+' Rq DateTime Not Null , '
+' Op_Number Char(10) Not Null , '
+' CName Char(10) Null , '
+' LogEvent Char(255) Null ) '
+' CREATE unique clustered index Logevent_Idx1 '
+' ON Logevent(Rq) '
);
try
Query1.ExecSQL;
except
application.Messagebox('创建事件日志信息表失败!','信息提示',Mb_ok);
exit;
end;
Query1.Close;
ListBox1.Items.Add(' ★ 事件日志信息表Logevent创建成功');
ListBox1.TopIndex := ListBox1.Items.Count-1;
ListBox1.Refresh;
end;