首页 | 新闻中心| 公司介绍| 产品走廊| 渠道与销售| 技术支持| 下载中心| 用户认证
蓝色快车PB俱乐部论坛--PowerBuilder MIS编程浏览:如何动态改编数据窗口的数据源
>>欢迎您,请先登陆 | 注册 | 发贴排行 | 搜索 | 帮助 | 退出
    蓝色快车PB俱乐部论坛
    PowerBuilder MIS编程
       浏览:如何动态改编数据窗口的数据源

  发表一个新主题  发表一个新投票 回复主题  您是本帖的第 1256 个阅读者
 * 贴子主题: 如何动态改编数据窗口的数据源 保存该页为文件 报告本帖给版主 显示可打印的版本  把本贴加入论坛收藏夹  把本贴加入IE收藏夹 

 掉线,给我留言吧!  cpu
  
  
  等级:论坛游民
 财产:
 经验:
 魅力:
  注册:2003-4-15
  文章:26
  鉴定:保密

  给cpu发送一个短消息 查看cpu的个人资料 搜索cpu在PowerBuilder  引用回复这个贴子 

发贴心情 如何动态改编数据窗口的数据源
This script demonstrates how to change the source of a Datawindow dynamically.  
 
  
Example: You want to switch from a SQL select to a procedure OR you want to change from one procedure to another OR from one select to another. It doesn't matter, as long as the source that you are changing to brings back the same result set as was originally defined for the Datawindow.  
  
Note1: You may change the source ONLY if the result set does not change (i.e., the number of, type of, and order of columns does not change.)  
  
Note2: You must predefine all possible arguments to the DataWindow ahead of time. Remember, just because you have an argument defined doesn't mean that you have to use it. But all necessary arguments must be pre-defined. Then the appropriate arguments are referenced by the select or the stored procedure.  
  
Note3: Update capability may be affected. For example, even if the new source brings back the same data as the old source, if the column names are different, your updateable column list will be invalid (because it was defined against the old columns, not the new).  
  
However, if the column names are the same, you should be able to redirect updates to the new table by doing a Modify on datawindow.table.updatetable.  
  
Example of changing from a select source to a stored procedure source  
  
1. Create a procedure in ASA using following syntax:  
  
CREATE procedure dbo.sp_test () as  
select department.dept_id,department.dept_name,employee.emp_lname from  
DBA.department,DBA.employee  
  
2. In PB, create a datawindow which has the same select statement as in the stored proc.  
  
3. Now, you can change the datasource in the script as follows:  
  
dept_name = "R&D  
  
w_1.Modify("datawindow.table.select =' ' )  
  
od_string = "datawindow.table.procedure = ' execute dbo.sp_test;0 '  
  
rc = dw_1.Modify(mod_string)  
  
F rc = " THEN  
  
dw_1.Retrieve ( dept_name, name_str)  
  
ELSE  
  
"Change to DW Source Failed)  
  
END IF  
  
* You can verify the change in the data source using 'dw_1.Object.Datawindow.Syntax'  
in the script.  
  
The following steps demonstrate how to change the source of a Datawindow from select to stored procedure permanently:  
  
1) Export your Datawindow to a DOS file (using the Library Painter.)  
  
2) Make a backup copy of the original file (in case you make a mistake and need to drop back!)  
  
) Using a text editor like Write or Notepad, open the file and replace the"retrieve = ...  
line. Using the above example, the "retrieve = line in my datawindow source code might look like this:  
  
epartment.dept_id~" )) )  
  
line in the Datawindow source code with the following "procedure = line (assumes the proc is owned by dbo)  
  
rocedure="execute dbo.sp_test;0  
  
After making the change, you would import the modified source code back into your PBL. That's it!  
  
Again, always be sure to make a backup copy of your Datawindow before you import any changes (just in case you inadvertently make a bad change to the source code.)

发贴时间: 2003/4/18 11:07:32 保密

页次:1/1页每页10 本主题贴数1

分页: [1]

 *快速回复:如何动态改编数据窗口的数据源 顶端 
你的用户名:   还没注册? 密码:   忘记密码?请与管理员联系
内容
  • HTML标签: 不可用
  • UBB标签: 允许
  • 贴图标签: 允许
  • Flash标签:允许
  • 表情字符转换:允许
  • 上传图片:允许
  • 最多16KB
  • 邮件回复 显示签名  [Ctrl+Enter直接提交贴子]

    ">