终于搞定PHP连接SQLServer2005.
为了php连接sql2005 ,我在网络上找了一大堆资料在我的csdn博客中.晚上3:05分时候终于搞定了 php连接sql2005的问题,现在整合,同时把FAQ整合上. 我前面写的教程: 连接前配置系统: 1.检查文件 php5.2.5\ntwdblib.dll 默认下面有一个,不能连接再替换. 下载正确版本的 ntwdblib.dll (2000.80.194.0),地址: http://webzila.com/dll/1/ntwdblib.zip 2.配置php a、打开php.in将extension=php_mssql.dll的注释符号去掉。 b、打开php.in将mssql.secure_connection = Off改为on。 c、将php_mssql.dll拷贝到php.in中extension_dir 指定的目录或者系统system32目录下。(php_mssql.dll在php的压缩安装包中有)。 以上步骤完成后需要重启apache。 注意:实际使用中发现 如果通过php压缩文件手工安装php到iis下,必须重启机器而不仅仅是iis。 3.配置sqlserver
a. 运行 SQL Server 配置管理器:SQL Server Configuration Manager,打开协议 Protocols
b. 允许命名管道 "named pipes" 和 "tcp/ip"
c. 右键点击 "tcp/ip",打开属性 Properties 标签 "IP addresses"
d. 在 TCP 动态端口 "TCP Dynamic Ports" 填入 1433
e. 重启 SQL Server -----------------------------------------------------------------------------------------------
4.使用以下方式连接MS SQL Server 2005:
代码如下: 输入http://127.0.0.1 ----------------------------------------------------------------------- 5.FAQ常见问题: 1报错: Fatal error: Call to undefined function mssql_connect() 解决: 使用MSSQL_系列函数
要使用这两种都需要在php.ini进行设定:
(1)允许 DCOM,需要将php.ini中的 ;com.allow_dcom=TRUE前的分号";"去掉。
(2)使用MSSQL扩展,需要php.ini中的 ;extension=php_mssql.dll前的分号";"去掉。(关键)
(3)确认extension_dir为正确路径,以本机为例:extension_dir = "c:\AppServ5.2.6\php\ext"。
(4)如果仍然机器报错说找不到c:\AppServ5.2.6\php\ext\php_mssql.dll但明明存在这个文件。
解决方法:将php_mssql.dll,ntwdblib.dll拷贝到系统目录\system32下重启测试。。
(注:上面两个dll文件不在相同目录下,我的为c:
相关文档:
由于以前都是在sqlserver 2005处理,现在客户要求oracle数据库服务器,
最初的代码为:
allRecordSize = (Integer) rs1.getObject(1); //Integer allRecordSize=0;
当执行的时候报:BigDecimal无法转化为Integer类型
为了兼容两者修改后的代码为:
Object o = rs1.getObject(1);
&nbs ......
create function comm_getpy
(
@str nvarchar(4000)
)
returns nvarchar(4000)
as
begin
declare @word nchar(1),@PY nvarchar(4000)
set @PY=''
while len(@str)>0
begin
set @word=left(@str,1)
--如果非汉字字符,返回原字符
& ......
一 在Oracle中连接数据库
public class Test1 {
public static void main(String[] args) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(
&nbs ......
sqlserver字符串拆分(split)方法汇总
--方法0:动态SQL法
declare @s varchar(100),@sql varchar(1000)
set @s='1,2,3,4,5,6,7,8,9,10'
set @sql='select col='''+ replace(@s,',',''' union all select ''')+''''
PRINT @sql
exec (@sql)
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ ......
declare @areaid varchar(100)
declare @areaname varchar(100)
declare Cur cursor for
select code as areaID,[name] as areaName from dbo.province
open Cur
Fetch next from Cur Into @areaid,@areaname
While @@fetch_status=0
Begin
print('insert into ......