PowerBuilder8.0动态连接SQL Server技巧

来源:互联网 发布:送餐软件哪个软件挣钱 编辑:程序博客网 时间:2024/05/21 16:02
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

                        PowerBuilder8.0动态连接SQL Server技巧

        我们都知道,一般情况下PB是和数据库结合最紧密的。那么,要掌握PB和数据库的连接是很重要的。因为数据库连接作为前后台关联的桥梁。下面我就将PowerBuilder8.03和Ms SQL Server2000的动态连接写出来和大家分享:

      首先,创建一个connect.ini文件,其内容为:                                                        [Database]
DBMS=MSSQL SQL Server 2000
Database=erp  
UserId=sa  
DatabasePassword=
LogId=sa
LogPassword=
ServerName=family
DbParm=
Lock=
Prompt=0          

其中:erp指您要连接的数据库名称;SA是数据库连接ID,Family是指您要连接的数据库的计算机名称,也可以用IP地址来代替。接下来,我们就在系统应用的Open事件中进行编码:                                                                                                                    string ls_inifile ="connect.ini"       

//进行数据库连接------------------------------------------------
SQLca.DBMS      = ProfileString ("dbconnect.INI", "database", "dbms",       "")
SQLca.database  = ProfileString ("dbconnect.INI", "database", "database",   "")
SQLca.logid     = ProfileString ("dbconnect.INI", "database", "logid",      "")
SQLca.logpass   = ProfileString ("dbconnect.INI", "database", "LogPassWord","")
SQLca.Servername=ProfileString("dbconnect.INI","database", "Servername",    "")
SQLca.dbparm    = ProfileString ("dbconnect.INI", "database", "dbparm",     "")
SQLca.autocommit=true;

connect using SQLca

If SQLca.SQLcode<>0 then  

    Messagebox("错误","不能连接到数据库!请检查数据库连接或者ini配置")

else

end if

      至此, PowerBuilder8.0动态连接SQL Server技巧基本上介绍完毕。写该文章的目的就是和大家进行交流。                                                                                             

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>