WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Examples from Users

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Column Insert Sample Code

Keywords: 	 LAFFDB column insert

AddExtender("Laffd34i.dll")
RunFile = IntControl (1004, 0, 0, 0, 0)
ProgName = FileRoot(RunFile)
ProgPath = FilePath(RunFile)
filename = StrCat(ProgPath,ProgName,".xls")
delimiter = @tab
RqdCols = StrCat("File",@tab,"Local_Path",@tab,"Net_Path")
DBMake = @false
If !FileExist(filename)
	handle = FileOpen(FileName,"Write")
	FileWrite(handle,RqdCols)
	FileClose(handle)
endif
;
bCreateOK = 0 ; if file does not exist, do create an empty database.
model = 2     ; traditional
numcols = -1   ; number of columns
format = 0
optionstring = ""
handle = dbOpen (filename, bCreateOK, model, numcols, format, delimiter, optionstring)
if handle == @LAFFDBERROR
	err = dbGetLastError()
	Message("Error Opening the database specified", err)
	exit
Endif
for x = 1 to 5
	column = dbGetColumnCount(handle) + 1
	ColName = StrCat("Column",column)
	; add a column to the database
	ret = dbInsertColumn (handle, column)
	if ret == @LAFFDBERROR
		err = dbGetLastError()
		Message("Error Inserting the Column", err)
	endif
	;**   Insert a name for the column in the database.
	ret = dbNameColumn(handle, column, ColName)
	if ret == @LAFFDBERROR
		err = dbGetLastError()
		Message("Error Naming the Column", err)
	endif
	;**   Bind the column in the database to a variable.
	ret = dbBindCol(handle, column, ColName)
	if ret == @LAFFDBERROR
		err = dbGetLastError()
		Message("Error Binding the column", err)
	endif
next
;***************************************************
;**   Display contents of new database
;***************************************************
dbdebug(handle)
;*****************************************************
;**   Saves Changes to database file 
;*****************************************************
ret = dbSave (handle, filename, "")
if ret == @LAFFDBERROR
	 err = dbGetLastError()
	 Message("Error Saving the database", err)
endif
;
;****************************************************
;**   Closes Database handle
;****************************************************
ret = dbClose(handle)
if ret == @LAFFDBERROR
	 err = dbGetLastError()
	 Message("Error Closing the database", err)
endif
exit


Article ID:   W15057
File Created: 2002:09:05:13:49:22
Last Updated: 2002:09:05:13:49:22