If FileWrite(li_filenum, ls_objname+"~r~n") = -1 Then
mle_status.Text = mle_status.Text +"~r~n"+"写入了文件+所有的dw中"+ls_objname
MessageBox('','写文件出错')
End If
FileClose(li_filenum)
End If
li_pos += li_namelen
Loop
FileClose(li_return)
li_j = li_i
End If
Next
MessageBox('提示','写文件完成')
end event
type dw_6 from datawindow within w_main
integer x = 96
integer y = 36
integer width = 686
integer height = 400
integer taborder = 10
string title = "none"
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type
上面的方法只能一个一个窗口的做.感觉很麻烦.
其实是可以找到每个数据窗口中使用了哪些表,然后再根据数据库中系统表的记录来得到一个结果.
下面这个你保存成srw文件导入到你的程序中看看,这个只完成了第一步得到数据窗口和表的对应关系
$PBExportHeader$w_main.srw
forward
global type w_main from window
end type
type dw_2 from datawindow within w_main
end type
type mle_status from multilineedit within w_main
end type
type cb_1 from commandbutton within w_main
end type
type dw_6 from datawindow within w_main
end type
end forward
global type w_main from window
integer width = 2606
integer height = 1616
boolean titlebar = true
string title = "得到数据窗口和表的对应关系"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
dw_2 dw_2
mle_status mle_status
cb_1 cb_1
dw_6 dw_6
end type
global w_main w_main
type variables
long ll_start, ll_used
end variables
forward prototypes
public subroutine wf_updatealldw (string as_dw, string as_pbl, string as_syntax)
end prototypes
String ls_tabname,ls_sql
String ls_a
Int li_cnt
SELECT count(*)
INTO :li_cnt
FROM sysobjects
where Name = 't_tablebydw';
If li_cnt < 1 Then
ls_sql = "CREATE TABLE [dbo].[t_tablebydw] ("&
+"[fdw] [varchar] (50) NULL ,"&
+"[fpbl] [varchar] (50) NULL ,"&
+"[ftable] [varchar] (100) NULL"&
+") ON [PRIMARY]"
EXECUTE Immediate :ls_sql;
If sqlca.SQLCode <> 0 Then
MessageBox('提示','创建表出现错误,~r~n错误信息为:'+sqlca.SQLErrText)
Else
End If
Else
// SELECT count(*)
// INTO :li_cnt
// From t_tablebydw;
// If li_cnt > 0 Then
// ls_sql = 'truncate table t_tablebydw'
// EXECUTE Immediate :ls_sql;
// If sqlca.SQLCode <> 0 Then
// MessageBox('提示','清空表出现错误,~r~n错误信息为:'+sqlca.SQLErrText)
// Else
// End If
// Else
// End If
End If
//select
DECLARE cur_tab CURSOR FOR
SELECT name
FROM sysobjects
WHERE ( sysobjects.xtype = 'u' ) OR
( sysobjects.xtype = 'v' )
order by sysobjects.Name;
OPEN cur_tab;
FETCH cur_tab Into :ls_tabname;
Do While sqlca.SQLCode = 0
If Pos(as_syntax,ls_tabname,1) > 0 Then //假如这个数据窗口调用了这个表
If IsNull(ls_a) Or ls_a = "" Then
ls_a = ls_tabname
Else
ls_a += "++"+ls_tabname
End If
Else
End If
FETCH cur_tab Into :ls_tabname;
Loop
//messagebox('',as_syntax)
INSERT INTO t_tablebydw
VALUES(:as_dw,:as_pbl,:ls_a)
COMMIT;
mle_status.Text = "在数据库中插入了值"+as_dw+"~r~n"+as_pbl+"~r~n"+ls_a