在SQLConnection1,如果通过属性连接了数据库,delphi自动产生的代码如下:
object SQLConnection1: TSQLConnection
ConnectionName = 'MSSQLConnection'
DriverName = 'MSSQL'
GetDriverFunc = 'getSQLDriverMSSQL'
LibraryName = 'dbexpmss.dll'
LoginPrompt = False
Params.Strings = (
'DriverName=MSSQL'
'HostName=192.168.0.200'
'DataBase=spdata'
'User_Name=sa'
'Password=test'
'BlobSize=-1'
'ErrorResourceFile='
'LocaleCode=0000'
'MSSQL TransIsolation=ReadCommited'
'OS Authentication=False')
VendorLib = 'oledb'
Connected = True
end请问:假如我要在模块创建时就要通过代码连接数据库,该如何写代码???
object SQLConnection1: TSQLConnection
ConnectionName = 'MSSQLConnection'
DriverName = 'MSSQL'
GetDriverFunc = 'getSQLDriverMSSQL'
LibraryName = 'dbexpmss.dll'
LoginPrompt = False
Params.Strings = (
'DriverName=MSSQL'
'HostName=192.168.0.200'
'DataBase=spdata'
'User_Name=sa'
'Password=test'
'BlobSize=-1'
'ErrorResourceFile='
'LocaleCode=0000'
'MSSQL TransIsolation=ReadCommited'
'OS Authentication=False')
VendorLib = 'oledb'
Connected = True
end请问:假如我要在模块创建时就要通过代码连接数据库,该如何写代码???
解决方案 »
- 用友cell 的几个问题??????????
- 请问如何用query1的控件来写动态的报表!谢谢
- xhh_88(三友)幫解決!
- 紧急求助,现场给分!ICS的WSocketServer1和WSocket进行通讯,如何用WSocketServer1返回信息给WSocket呀?WSocket又是如何接收?多谢!!
- sos~
- ADO链ACCESS的数据库应用程序,为什么编译后的EXE文件在别的机器上运行不了??(急!在线等候)
- 公农历转换(急!!!!)
- 请问:怎么让提示框中有“所有都是”或“所有都否”的选项?
- 窗体上光标的问题,很简单!
- 寻求课程设计:工资管理系统原代码,哪里有下载?
- 如何把窗体写到DLL文件中,让其他程序调用?到哪里能找到资料呢!
- 求救高手,怎么使用DEVexpress inspector组件
有谁能帮我吗?
begin
SQLConnection1.Params.Text:='DriverName=MSSQL'+#13+
'HostName=192.168.0.1'+#13+
'DataBase=dds'+#13+
'User_Name=sa'+#13+
'Password=sa'+#13+
'BlobSize=-1'+#13+
'ErrorResourceFile='+#13+
'LocaleCode=0000'+#13+
'MSSQL TransIsolation=ReadCommited'+ #13+
'OS Authentication=False'; SQLConnection1.ConnectionName:='111111';
SQLConnection1.DriverName:='MSSQL';
SQLConnection1.GetDriverFunc:= 'getSQLDriverMSSQL';
SQLConnection1.LibraryName:='dbexpmss.dll';
SQLConnection1.VendorLib:='oledb';
SQLConnection1.LoginPrompt:=false;
try
SQLConnection1.Connected:=true;
Showmessage('连接成功');;
except
Showmessage('连接失败');
end;end;
如果要静态连接,请双击SQLConnection1,再一一设置属性
begin
SQLConnection1.Params.Text:='DriverName=MSSQL'+#13+
'HostName=192.168.0.200'+#13+
'DataBase=spdata'+#13+
'User_Name=sa'+#13+
'Password=test'+#13+
'BlobSize=-1'+#13+
'ErrorResourceFile='+#13+
'LocaleCode=0000'+#13+
'MSSQL TransIsolation=ReadCommited'+ #13+
'OS Authentication=False'; SQLConnection1.ConnectionName:='111111';
SQLConnection1.DriverName:='MSSQL';
SQLConnection1.GetDriverFunc:= 'getSQLDriverMSSQL';
SQLConnection1.LibraryName:='dbexpmss.dll';
SQLConnection1.VendorLib:='oledb';
SQLConnection1.LoginPrompt:=false;
try
SQLConnection1.Connected:=true;
Showmessage('连接成功');;
except
Showmessage('连接失败');
end;end;