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

LAFFDB (obsolete)
plus

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

dbGetEntireRecord Quotes


Question:

I have been trying to have a free form text field where a user can enter in hyperlinks into my database.

Using the laffdb extender, I can write out a database field with a href link in it (including quotes), however when I read the field back, I loose my quotes, and the record is truncated.

Any ideas?

Here is my sample code to recreate this

AddExtender("laffd34i.dll")

FileName = "c:\temp\test.db"
delimiter = "|"
bCreateOK = 1 ; if file does not exist, 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)
   bErrorLevel = -1
Else
   For RecordNum = 1 To 2
      ret = dbBindCol(handle, 1, "Name")
      ret = dbBindCol(handle, 2, "Descriptions")
      If ret == @LAFFDBERROR
         err = dbGetLastError()
         Message("Error Binding the column", err)
         bErrorLevel = -2
      Else
         ret = dbGetEntireRecord(handle, RecordNum, 1)
         If ret == @LAFFDBERROR
            ;Don't say if we can't read the record
            ;err = dbGetLastError()
            ;Message("Error getting entire record", err)
            bErrorLevel = -3
         Else
            If RecordNum == 1 Then
               Message('Record 1 works fine',StrCat(Name,@TAB,Descriptions))
            Else
               Message('Record 2 line should be [<a href="e:\temp\test.txt">tester</a> is a test]',StrCat(Name,@TAB,Descriptions))
            End If
         End If
      End If
   Next xloop
   ret = dbClose(handle)
End If
Exit
test.db should look like this
Name|Descriptions
test|Really Big Line Of Text!!!!!!! Really Big Line Of Text!!!!!!!
test|<a href="e:\temp\test.txt">tester</a> is a test

Answer:

You may need to some special processing for quotes. Maybe right before you write daya do something like
var=StrReplace(var,'"','""')

User Reply:

Since this is a free form field we are entering in data, there may be a mix of any kind of characters in there!

I could replace the '"' with @, however if someone enters a legitimate @ in their comment, the next time, I may replace that with a '"'.

Answer:

Either double up the quotes or perhaps choose a high-ascii character unlikely to be used in the US. It is a "light" database with limited features.

User Reply:

Thanks for your help.

Weird that is can write out quotes with no problem, but not read them!

Maybe you could add this caveat to the help file so other's like me don't tread down this path.

Answer:

It is in the help file: A single character separator, such as a tab or a comma. Fields containing the character separator must use quote marks to indicate a single field. Any field may be delimited by quotemarks. All leading and trailing quote marks of any field are stripped. Quotes within a field are represented by two ajoining quotes

Example:

123,John Doe,Bellevue 12d,"Flintstone,Fred",45,"1,000.00","GratuitiousQuotesAreLegal"

A space or multiple spaces. Text fields with multiple words must use quote marks to indicate a single column. Quotes within a field are represented by two ajoining quotes

Example:

123 “John Doe” Bellevue "Yes ""She said"""

Article ID:   W16829
File Created: 2007:07:03:14:26:28
Last Updated: 2007:07:03:14:26:28