如何连接到sql服务器,并验证SA的密码?

sdweihailh 2005-10-06 09:51:04
delphi如何连接到sql服务器,并验证SA的密码,验证通过以后,如何在SQL服务器上,新建一个数据库a,并在数据库a上新建一个表b,最好是给出源码?跪求!!
...全文
141 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
cdsgajxlp 2005-10-06
  • 打赏
  • 举报
回复
adocommand1.ConnectionString:='Provider=SQLOLEDB.1;Password=sa'+
';Persist Security Info=True;User ID=sa'+
';Initial Catalog=Master'+
';Data Source=127.0.0.1';
adocommand1.CommandText:='use master';
adocommand1.Execute;
adocommand1.CommandText:='....';//创建数据库
adocommand1.Execute;
常遇道 2005-10-06
  • 打赏
  • 举报
回复
已前的建庫你試試吧
CREATE DATABASE database_name
[ ON [PRIMARY]
[ <filespec> [,...n] ]
[, <filegroup> [,...n] ]
]
[ LOG ON { <filespec> [,...n]} ]
[ FOR LOAD | FOR ATTACH ]

<filespec> ::=

( [ NAME = logical_file_name, ]
FILENAME = 'os_file_name'
[, SIZE = size]
[, MAXSIZE = { max_size | UNLIMITED } ]
[, FILEGROWTH = growth_increment] ) [,...n]

<filegroup> ::=

FILEGROUP filegroup_name <filespec> [,...n]
--------------------------------------------------
以下是建表
{ Don't overwrite an existing table }

if not Table1.Exists then begin
with Table1 do begin
{ The Table component must not be active }
Active := False;
{ First, describe the type of table and give }
{ it a name }
DatabaseName := 'DBDEMOS';
TableType := ttParadox;
TableName := 'CustInfo';
{ Next, describe the fields in the table }
with FieldDefs do begin
Clear;
with AddFieldDef do begin

Name := 'Field1';
DataType := ftInteger;
Required := True;
end;
with AddFieldDef do begin
Name := 'Field2';
DataType := ftString;
Size := 30;
end;
end;
{ Next, describe any indexes }
with IndexDefs do begin
Clear;
{ The 1st index has no name because it is
{ a Paradox primary key }
with AddIndexDef do begin

Name := '';
Fields := 'Field1';
Options := [ixPrimary];
end;
with AddIndexDef do begin
Name := 'Fld2Indx';
Fields := 'Field2';
Options := [ixCaseInsensitive];
end;
end;
{ Call the CreateTable method to create the table }
CreateTable;
end;
end;
--------------------------------------
在DELPHI幫助裡可以找到相關的資料

2,497

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧