PB9连接SQL Server 2005全面指南

需积分: 10 1 下载量 108 浏览量 更新于2024-09-07 收藏 352KB DOC 举报
"这篇文档详细介绍了如何使用PowerBuilder (PB9) 连接至SQL Server 2005的方法,包括必要的系统配置和SQL Server设置。" 在尝试使用PowerBuilder 9 (PB9) 连接至SQL Server 2005时,可能会遇到连接问题。以下是解决这些问题的关键步骤: 1. **复制ntwdblib.DLL**:为了能够配置DBMS为"MSS Microsoft SQL Server",需要将ntwdblib.DLL文件复制到C:\WINDOWS\system32目录下。 2. **启动SQL Server服务和关闭防火墙**:确保SQL Server服务已启动,同时关闭Windows防火墙,以便PB9能够顺利连接。 3. **检查1433端口状态**:使用`netstat -an`命令检查本地1433端口是否在监听。如果未启动,需要在"SQL Server配置管理器"中启用SQL Server 2005网络协议中的TCP/IP。 4. **配置TCP/IP协议**:在"SQL Server 2005网络协议"中,确保所有必要的IP地址都启用了,并且配置正确的端口号,通常是1433。 5. **配置远程连接**:在"SQL Server外围应用配置器"中,更改Database Engine的远程连接设置,选择"本地连接和远程连接",同时使用TCP/IP和named pipes。 6. **身份验证模式**:在"SQL Server企业管理器"中,将服务器的身份验证模式设置为"SQL Server和Windows身份验证模式"。 7. **管理登录账户**:在"安全性"->"登录名"下,确保SA用户或创建新账户,并设置适当的密码。 8. **解决UAC问题**:针对Windows 7用户,由于用户账户控制(UAC),可能需要以管理员权限运行"SQL Server企业管理器",或临时禁用UAC。不关闭防火墙的情况下,还需确保SQL Server Services和SQL Server Browser Services被添加到防火墙例外列表中,以及TCP端口SQLSer。 以上步骤是解决PB9连接SQL Server 2005问题的关键,执行这些操作后,应该能够成功建立连接。如果在过程中遇到错误,比如18456错误码,可参照上述解决UAC的方法来处理。在整个过程中,确保每一步都按照指示进行,避免因配置错误导致连接失败。

select c.area_name,c.mon,c.count,ifnull(c1.count1,0),ifnull(c1.count1,0)/count * 100 from ( select a.area_name,MONTH(pb.wlpb_create_time) mon,count(pb.id) count from bc_company_info b inner join ( select b.id from wk_ledger_produce_gather g left join bc_company_info b on b.id =g.bci_id where g.wlpg_year =2022 group by b.id HAVING sum(g.wlpg_total_produce) >=30 UNION select b.id from wk_plan_info p left join wk_plan_danger d on d.wpi_id = p.id left join bc_company_info b on b.id = p.bci_id where p.wpi_year = 2022 group by b.id HAVING sum(d.wpd_this_produce) >30) b1 on b1.id = b.id left join wk_ledger_produce_bill pb on pb.bci_id = b.id left join sys_area a on a.id = b.bci_city where pb.wlpb_create_time >'2023-01-01 00:00:00' group by b.bci_city,MONTH(pb.wlpb_create_time) ) c left join ( select a.area_name,MONTH(pb.wlpb_create_time) mon,count(pb.id) count1 from bc_company_info b inner join ( select b.id from wk_ledger_produce_gather g left join bc_company_info b on b.id = g.bci_id where g.wlpg_year =2022 group by b.id HAVING sum(g.wlpg_total_produce) >=30 UNION select b.id from wk_plan_info p left join wk_plan_danger d on d.wpi_id = p.id left join bc_company_info b on b.id = p.bci_id where p.wpi_year = 2022 group by b.id HAVING sum(d.wpd_this_produce) >30) b1 on b1.id = b.id left join wk_ledger_produce_bill pb on pb.bci_id = b.id left join sys_area a on a.id = b.bci_city where pb.wldb_end_from != 1 and pb.wlpb_create_time >'2023-01-01 00:00:00' group by b.bci_city,MONTH(pb.wlpb_create_time)) c1 on c.area_name = c1.area_name and c.mon = c1.mon 这段SQL怎么优化

2023-06-09 上传