Delphi使用ini配置文件连接MS SQL数据库
很早做过的一个delphi项目,把里面用到的技术总结一下,主要是针对象我这样的delphi新手,技术上做个积累吧!
假设我们的数据库配置文件ServerInfo.ini内容如下:
[ServerInfo]
ServerIP=192.168.1.5
SQLDBName=Data
SQLUserID=sa
SQLPwd=
我们定义一个连接数据库的过程DBConnect内容应如下
procedure TDM.DBConnect();
var
ini:TiniFile;
Server,User,Pass,DBName:string;
begin
ini := TiniFile.Create(ExtractFilePath(Application.ExeName)+'dbconn.ini'); //初始化ini文件
Server := ini.ReadString('serverinfo','ServerIP',''); //数据库ip地址
DBName := ini.ReadString('serverinfo','SQLDBName',''); //数据库名
User := ini.ReadString('serverinfo','SQLUserID',''); //数据库用户名
Pass := ini.ReadString('serverinfo','SQLPwd',''); //数据库密码
try
DM.ADOConn.ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;'
+'User ID='+trim(User)
+';Password='+trim(Pass)
+';Initial Catalog='+trim(DB)
+';Data Source='+trim(Server);
DM.ADOConn.Open ;
except
application.MessageBox('数据库连接失败,请检查INI配置文件','提示',64);
application.Terminate ;
end;
end;
相信大家都能看懂,注意使用TiniFile类的函数或过程应引入INIFiles单元。
相关文档:
merge [target] t
using [source] s on t.id = s.id
when matched then update t.name = s.name, t.age = s.age -- use "rowset1"
when not matched then insert values(id,name,age) -- use "rowset2"
when source not matched then delete; -- use "rowset3"
MERGE dbo.table AS im ......
CONVERT
将某种数据类型的表达式显式转换为另一种数据类型。由于某些需求经常用到取日期格式的不同.现以下可在
SQL Server中 将日期格式化.
SQL Server 支持使用科威特算法的阿拉伯样式中的数据格式。
在表中,左侧的两列表示将 datetime 或 smalldatetime 转换为字符数据的 style 值。给 style 值加 100,可获得包 ......
用sql操作oracle的blob字段
1、查询
select utl_raw.cast_to_varchar2(dlob),id from system.t_htinfo
2、插入
insert into system.t_htinfo values ('3',utl_raw.cast_to_raw('你'));
3、更新
update system.t_htinfo set fld_value=utl_raw.cast_to_raw('1') where fh_nm=1820648 and form_index=52
......
操
作系统的支持
版
本和发行版
实
例、数据库和表空间
实
例名和SID
系
统数据库和系统表空间
本译文采用知识共享署
名-非商业性使用-相同方式共享 3.0 Unported许可协议
发布,转载请保留此信息
译者:马齿苋 | 链接:http://www.dbabeta.com/2010/oracle-sql-server-comparison-i.html
作者:S ......