ehxz 发表于 2008-9-10 09:38:32

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

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:

0End of file; too many rows
-1No rows
-2Empty file
-3Invalid argument
-4Invalid input
-5Could not open the file
-6Could not close the file
-7Error reading the text
-8Not a TXT file
-9The 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

ehxz 发表于 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.

zhangyh_136 发表于 2008-9-10 16:53:36

最好不用importfile,如果数据量大(上万条,甚至更多,pb就会遗漏数据)

ehxz 发表于 2008-9-11 09:16:33

那用啥好,因为目前的数据量不会那么大,至多上K数据。
页: [1]
查看完整版本: 数据窗口DW在importfile是的返回值问题

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

Mail To:Admin@SybaseBbs.com