祝愿大家身体健康!

 站点注册  找回密码
 站点注册

QQ登录

只需一步,快速开始

查看: 10986|回复: 3

数据窗口DW在importfile是的返回值问题

[复制链接]

数据窗口DW在importfile是的返回值问题

[复制链接]
ehxz

主题

0

回帖

58万

积分

管理员

积分
588551
贡献
在线时间
小时
2008-9-10 09:38:32 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?站点注册

×
datawindowname.importfile(filename,startrow,endrow,startcolumn,endcolumn,dwstartcolumn)   
   
  返回值   
  -3   非法参数   
  -4   非法输入   
  -5   不能打开文件   
  -6   不能关闭文件   
  -7   错误读取文本   
  -8   不是txt文件

PB里的帮助说明:6.5

Description
Inserts data into a DataWindow control or DataStore from a file. The data can be tab-delimited text or dBase format 2 or 3.
Controls
DataWindow controls, DataStore objects, and child DataWindows
Syntax

dwcontrol.ImportFile ( filename {, startrow {, endrow {, startcolumn         {, endcolumn {, dwstartcolumn } } } } } )
Argument        Description
dwcontrol        The name of the DataWindow control or DataStore to which you want to copy data from the specified file
filename        A string whose value is the name of the file from which you want to copy data. The file must be an ASCII, tab-delimited file (TXT) or a dBase format 2 or 3 file (DBF). Specify the file's full name, which must end in the appropriate extension.If filename is NULL, ImportFile displays the File Open dialog box and allows the user to select a file
startrow (optional)        The number of the first row in the file that you want to copy. If the first row contains headings that you want to skip, set startrow to 2. The default is 1
endrow (optional)        The number of the last row in the file that you want to copy. The default is the rest of the rows
startcolumn (optional)        The number of the first column in the file that you want to copy. The default is 1
endcolumn (optional)        The number of the last column in the file that you want to copy. The default is the rest of the columns
dwstartcolumn (optional)        The number of the first column in the DataWindow control or DataStore that you want to receive data. The default is 1
ImportFile may trigger an ItemError event.
Return value
Long. Returns the number of rows that were imported if it succeeds and one of the following negative integers if an error occurs:

0  End of file; too many rows
-1  No rows
-2  Empty file
-3  Invalid argument
-4  Invalid input
-5  Could not open the file
-6  Could not close the file
-7  Error reading the text
-8  Not a TXT file
-9  The user canceled the import
-10 Unsupported dBase file format (not version 2 or 3)

Usage

The file should consist of rows of data. If the file includes column headings or row labels, set the startrow and startcolumn arguments to skip them. The data types and order of the DataWindow object's columns must match the columns of data in the file.

The startcolumn and endcolumn arguments control the number of columns imported from the file and the number of columns in the DataWindow that are affected. The dwstartcolumn argument specifies the first DataWindow column to be affected. The following formula calculates the last DataWindow to be affected.

dwstartcolumn + (endcolumn - startcolumn)

To let users select the file to import, specify a NULL string for filename. PowerBuilder displays the Select Import File dialog box. A dropdown listbox lets the user select the type of file to import.

Importing files into the ANSI and Unicode versions of PowerBuilder  

The type of file that can be imported using the ImportFile function varies depending on the file's format and the version of PowerBuilder you are running.
File type        File format that can be imported
.TXT        Only Unicode files can be imported into the Unicode version of PowerBuilder. Unicode files cannot be imported into the ANSI version of PowerBuilder
.DBF        Files created using either the ANSI or Unicode version of PowerBuilder can be imported into both versions
共享共进共赢Sharing And Win-win Results
SYBASEBBS - 免责申明1、欢迎访问“SYBASEBBS.COM”,本文内容及相关资源来源于网络,版权归版权方所有!本站原创内容版权归本站所有,请勿转载!
2、本文内容仅代表作者观点,不代表本站立场,作者自负,本站资源仅供学习研究,请勿非法使用,否则后果自负!请下载后24小时内删除!
3、本文内容,包括但不限于源码、文字、图片等,仅供参考。本站不对其安全性,正确性等作出保证。但本站会尽量审核会员发表的内容。
4、如本帖侵犯到任何版权问题,请立即告知本站 ,本站将及时删除并致以最深的歉意!客服邮箱:admin@sybasebbs.com
ehxz 楼主

主题

0

回帖

58万

积分

管理员

积分
588551
贡献
在线时间
小时
2008-9-10 10:22:39 | 显示全部楼层
pb11里的帮助说明:
Description
Inserts data into a DataWindow control or DataStore from a file. The data can be tab-separated text, comma-separated text, XML, or dBase format 2 or 3.
Controls
DataWindow type Method applies to
PowerBuilder DataWindow control, DataWindowChild object, DataStore object
Web ActiveX DataWindow control, DataWindowChild object
Syntax
PowerBuilder   
long dwcontrol.ImportFile ( {saveastype importtype}, string filename {, long startrow {, long endrow {, long startcolumn {, long endcolumn {, long dwstartcolumn } } } } } )
Web ActiveX   
number dwcontrol.ImportFile ( number importtype, string string, number startrow, number endrow, number startcolumn, number endcolumn, number dwstartcolumn )
Argument Description
dwcontrol A reference to a DataWindow control or DataStore
importtype
(optional for PowerBuilder) An enumerated value of the SaveAsType DataWindow constant or a number representing that value (see SaveAsType). If this argument is specified, the filename argument can be specified without an extension. Valid type arguments for ImportFile are:Text!CSV!XML!DBase2!DBase3!
filename A string whose value is the name of the file from which you want to copy data. The file must be an ASCII, tab-separated file (TXT) or a comma-separated file (CSV), Extensible Markup Language file (XML), or dBase format 2 or 3 file (DBF). Specify the file's full name. If the optional importtype is not specified, the name must end in the appropriate extension.If filename is an empty string, or if it is null, ImportFile displays the File Open dialog box and allows the user to select a file. The remaining arguments are ignored.
startrow
(optional for PowerBuilder) The number of the first detail row in the file that you want to copy. The default is 1. For default XML import, if startrow is supplied, the first N (startrow -1) elements are skipped, where N is the DataWindow row size.For template XML import, if startrow is supplied, the first  (startrow -1) occurrences of the repetitive row mapping defined in the template are skipped.
endrow
(optional for PowerBuilder) The number of the last detail row in the file that you want to copy. The default is the rest of the rows. For default XML import, if endrow is supplied, import stops when N * endrow elements have been imported, where N is the DataWindow row size.For template XML import, if endrow is supplied, import stops after endrow occurrences of the repetitive row mapping defined in the template have been imported.
startcolumn (optional for PowerBuilder) The number of the first column in the file that you want to copy. The default is 1. For default XML import, if startcolumn is supplied, import skips the first (startcolumn - 1) elements in each row.This argument has no effect on template XML import.
endcolumn (optional for PowerBuilder) The number of the last column in the file that you want to copy. The default is the rest of the columns.For default XML import, if endcolumn is supplied and is smaller than N, where N is the DataWindow row size, import skips the last (N - endcolumn) elements in each row.This argument has no effect on template XML import.
dwstartcolumn (optional for PowerBuilder) The number of the first column in the DataWindow control or DataStore that should receive data. The default is 1. This argument is supported for default and template XML import.
Return value
Long. Returns the number of rows that were imported if it succeeds and one of the following negative integers if an error occurs:
-1   No rows or startrow value supplied is greater than the number of rows in the file
-2   Empty file
-3   Invalid argument
-4   Invalid input
-5   Could not open the file
-6   Could not close the file
-7   Error reading the text
-8   Unsupported file name suffix (must be *.txt, *.csv, *.dbf or *.xml)
-10   Unsupported dBase file format (not version 2 or 3)
-11   XML Parsing Error; XML parser libraries not found or XML not well formed
-12   XML Template does not exist or does not match the DataWindow
-13    Unsupported DataWindow style for import
-14    Error resolving DataWindow nesting
-15    File size exceeds limit
Usage
The format of the file can be indicated by specifying the optional importtype parameter, or by including the appropriate file extension.
The file should consist of rows of data. If the file includes column headings or row labels, set the startrow and startcolumn arguments to skip them. The datatypes and order of the DataWindow object's columns must match the columns of data in the file.
The startcolumn and endcolumn arguments control the number of columns imported from the file and the number of columns in the DataWindow that are affected. The dwstartcolumn argument specifies the first DataWindow column to be affected. The following formula calculates the last DataWindow to be affected.
dwstartcolumn + (endcolumn - startcolumn)
To let users select the file to import, specify a null string for filename. PowerBuilder displays the Select Import File dialog box. A drop-down list lets the user select the type of file to import.
Specifying a null string for filename      If you specify a null string for filename, the remaining arguments are ignored. All the rows and columns in the file are imported.
Double quotes    The location and number of double quote marks in a field in a tab-separated file affect how they are handled when the file is imported. If a string is enclosed in one pair of double quotes, the quotes are discarded. If it is enclosed in three pairs of double quotes, one pair is retained when the string is imported. If the string is enclosed in two pairs of double quotes, the first pair is considered to enclose a null string, and the rest of the string is discarded.
When there is a double quote at the beginning of a string, any characters after the second double quote are discarded. If there is no second double quote, the tab or comma character delimiting the fields is not recognized as a field separator and all characters up to the next occurrence of a double quote, including a carriage return, are considered to be part of the string. A validation error is generated if the combined strings exceed the length of the first string.
Double quotes after the first character in the string are rendered literally. Here are some examples of how tab-separated strings are imported into a two-column DataWindow:
Text in file Result
"Joe" TAB "Donaldson" Joe Donaldson
Bernice TAB """Ramakrishnan""" Bernice "Ramakrishnan"
""Mary"" TAB ""Li"" Empty cells
"Mich"ael TAB """Mariam""" Mich "Mariam"
"Amy TAB Doherty" Amy<TAB>Doherty in first cell, second cell empty
3""" TAB 4" 3""" 4"
If an XML or CSV column contains a leading double quote, it is assumed to be part of the column value. A leading double quote has to be closed to mark the end of an item.
ImportFile does not support Crosstab DataWindow objects.
共享共进共赢Sharing And Win-win Results
zhangyh_136

主题

0

回帖

3

积分

新手上路

积分
3
贡献
在线时间
小时
2008-9-10 16:53:36 | 显示全部楼层
最好不用importfile,如果数据量大(上万条,甚至更多,pb就会遗漏数据)
共享共进共赢Sharing And Win-win Results
ehxz 楼主

主题

0

回帖

58万

积分

管理员

积分
588551
贡献
在线时间
小时
2008-9-11 09:16:33 | 显示全部楼层
那用啥好,因为目前的数据量不会那么大,至多上K数据。
共享共进共赢Sharing And Win-win Results
您需要登录后才可以回帖 登录 | 站点注册

本版积分规则

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com

QQ|Archiver|PowerBuilder(PB)BBS社区 ( 鲁ICP备2021027222号-1 )

GMT+8, 2024-11-22 13:20 , Processed in 0.032189 second(s), 8 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表