Bug in DBConnection class>>connectString:do:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug in DBConnection class>>connectString:do:

Chris Uppal-3
Hi,

I was messing around trying to use Dolphin plus the ODBC interface to .CVS
files and hit a problem with the connectString parsing.  The driver name (which
is included in the string returned by Windows) is something like:
        Microsoft Text Driver (*.txt; *.csv)
which contains a ';', thus breaking the parser.

The MS documentation for the string format is (typically) vague but it appears
that values containing semi-colons are supposed to be represented by name/value
pairs like:
    Driver={Microsoft Text Driver (*.txt; *.csv)};

I've appended a modified version of DBConnection class>>connectString:do: which
is working OK for me so far, although I have not attempted to do any real
testing.

    -- chris


=======================
connectString: aString do: aTwoArgBlock
 "Private - Interpret the connection string and pass the parameter name and
value from each $; separated
 substring to aTwoArgBlock."

 | stream |
 stream := aString readStream.

 [| paramName paramValue |

  "advance over any odd ;-s"
  [stream peekFor: $;] whileTrue.
  stream atEnd ifTrue: [^ self].

  "the stuff up to the next '=' is the name"
  paramName := stream upTo: $=.
  stream atEnd ifTrue: [^ self].

  "if the next char is '{' then assume we've got a '{}'-delimited value,
  otherwise the value is all the stuff up to the next ;"
  paramValue := (stream peekFor: ${)
    ifTrue: [stream upTo: $}]
    ifFalse: [stream upTo: $;].

  aTwoArgBlock value: paramName value: paramValue.
 ] repeat.
=======================


Reply | Threaded
Open this post in threaded view
|

Re: Bug in DBConnection class>>connectString:do:

Blair McGlashan-2
"Chris Uppal" <[hidden email]> wrote in message
news:3ffd80f2$0$61053$[hidden email]...
> Hi,
>
> I was messing around trying to use Dolphin plus the ODBC interface to .CVS
> files and hit a problem with the connectString parsing.  The driver name
... contains a ';', thus breaking the parser.

Thanks Chris, #1473.

Regards

Blair