用记事本打开UDL文件,Initial
Catalog=后面的就是数据库名字
写程序 *** 作的话就这样
1,把你的udl文件改成这样的格式,就是一行一条数据
[oledb]
;
Everything
after
this
line
is
an
OLE
DB
initstring
Provider=SQLOLEDB1;
Integrated
Security=SSPI;
Persist
Security
Info=False;
Initial
Catalog=数据库名
2,写程序把UDL文件中的数据库名显示在Label1里
uses
IniFiles;
procedure
TForm1Button1Click(Sender:
TObject);
var
f
:TIniFile;
begin
f
:=
TIniFileCreate('UDL文件的位置');
Label1Caption
:=
fReadString('oledb','Initial
Catalog','');
fFree;
end;
在SQLServer上得到客户端信息( *** 作的数据库名,计算机名,用户名,网卡物理地址,IP地址,程序名)\x0d\createprocp_getlinkinfo\x0d\@dbnamesysname=null,--要查询的数据库名,默认查询所有数据库的连接信息\x0d\@includeipbit=0--是否显示IP地址,因为查询IP地址比较费时,所以增加此控制\x0d\as\x0d\declare@dbidint\x0d\set@dbid=db_id(@dbname)\x0d\createtable#tb(idintidentity(1,1),dbnamesysname,hostnamenchar(128),loginnamenchar(128),net_addressnchar(12),net_ipnvarchar(15),prog_namenchar(128))\x0d\insertinto#tb(hostname,dbname,net_address,loginname,prog_name)\x0d\selectdistincthostname,db_name(dbid),net_address,loginame,program_namefrommastersysprocesses\x0d\wherehostname''and(@dbidisnullor)\x0d\if@includeip=0gotolb_show--如果不显示IP地址,就直接显示\x0d\declare@sqlvarchar(500),@hostnamenchar(128),@idint\x0d\createtable#ip(hostnamenchar(128),avarchar(200))\x0d\declaretbcursorlocalforselectdistincthostnamefrom#tb\x0d\opentb\x0d\fetchnextfromtbinto@hostname\x0d\while@@fetch_status=0\x0d\begin\x0d\set@sql='ping'+@hostname+'-a-n1-l1'\x0d\insert#ip(a)execmasterxp_cmdshell@sql\x0d\update#ipsetwherehostnameisnull\x0d\fetchnextfromtbinto@hostname\x0d\end\x0d\update#tbsetnet_ip=left(a,patindex('%:%',a)-1)\x0d\from#tbainnerjoin(\x0d\selecthostname,a=substring(a,patindex('Pingstatisticsfor%:%',a)+20,20)from#ip\x0d\wherealike'Pingstatisticsfor%:%')bonahostname=bhostname\x0d\lb_show:\x0d\selectid,数据库名=dbname,客户机名=hostname,用户名=loginname\x0d\,网卡物理地址=net_address,IP地址=net_ip,应用程序名称=prog_namefrom#tb\x0d\GO\x0d\\x0d\//显示所有本机的连接信息:\x0d\execp_getlinkinfo\x0d\//显示所有本机的连接信息,包含ip地址:\x0d\execp_getlinkinfo@includeip=1\x0d\//显示连接指定数据库的信息:\x0d\execp_getlinkinfo@dbname=表名,@includeip=1
1、获得所有数据库名
选择master数据库,查询表sysdatabases;
2、获得所有数据表名
选择你要查询的数据库,查询表sysobjects,并且xtype为'U';
3、获得所有字段名和字段类型
选择你要查询的数据库,查询表syscolumns,语句如下:
select
bname, aname, cname
from syscolumns a
inner join sysobjects b on aid = bid
inner join systypes c on axtype = cxtype
Select name from mastersysdatabases
where name not in('master','model','msdb','tempdb','northwind','pubs')
以上就是关于在delphi中如何获得.udl文件中的数据库名呢全部的内容,包括:在delphi中如何获得.udl文件中的数据库名呢、SQLserver怎么获取当前 *** 作数据库的计算机名字、sqlserver 如何获得所有数据库名 如何获得已知数据库所有表名 和 已知表明获得所有字段名和字段类型等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)