Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import Problem Code

Status
Not open for further replies.

woodyinoz

IS-IT--Management
Jan 8, 2002
215
GB
I have been using the following code to try and import a text file into a specified table but when it comes to attaching strValue to the dthandle. setSource I come up against a problem because it does not recognise it. I think I'm very close to cracking this but it has now turned me into circles!!

Can anyone help?

method pushButton(var eventInfo Event)

var
dtHandle DataTransfer
lEditState Logical
tvTable TableView
fbiXfile FileBrowserInfo
loRetval Logical
strValue String
endvar

;initialise local vars
loRetval = TRUE
strValue = "IMPORT.TXT"

fbiXfile.Options = browseOptPathMustExit
fbiXfile.AllowableTypes = fbtext + fbfiles
fbiXfile.Alias = ":partMan:"
fbiXfile.DefaultExt = "TXT"

loRetval = getFileName(strValue, fbiXfile)

if loRetval then

msginfo ("FYI", "You have chosen to import " + strvalue + ".")

endif

;// Set notification for user
;//
setMouseShape(MOUSEWAIT, TRUE)

dtHandle.setSource (strValue) ;//PROBLEM AREA
dtHandle.setSourceCharSet(dtANSI)

;// Enable the key violation and problems tables
;//
dtHandle.setKeyViol(TRUE)
dtHandle.setProblems(TRUE)

;// The import does not start on line 1
;//
dtHandle.setSourceStartRow(2)

;// Setup delimited import options
;//
dtHandle.setSourceSeparator(",")
dtHandle.setSourceDelimiter("\"")
dtHandle.setSourceDelimitedFields(dtDELIMALLFIELDS)

;// We are always appending in this script since we force the
;// destination table to always exist
;//
dtHandle.setDest(":partMan:partReport.DB")
dtHandle.setAppend(TRUE)

;// Reset cursor for the user
;//
setMouseShape(MOUSEARROW, TRUE)

;// Confirm the import
;//
if msgQuestion("Importing Data",
"You are about to import new contract data. Are you sure?") = "Yes" then

setMouseShape(MOUSEWAIT, TRUE)

;// Perform the import
;//
dtHandle.transferData()

;// Display table
;//
tvTable.open(":partMan:partReport.DB")

else

setMouseShape(MOUSEARROW, TRUE)

endif

endMethod

Thanks,

Woody
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top