Syntax Error?

  • Thread starter Thread starter CBT
  • Start date Start date
C

CBT

I am trying to connect to an AS400. I can see the files in my Data
Connections, but the following code is generating this message:
"Comma, ')', or a valid expression continuation expected". The code
is:

Dim objConnection As New OleDb.OleDbConnection( _
"Provider=MSDASQL.1;Persist Security Info=False;User ID=abc;Data
Source=MyAS400;Extended Properties="DSN=MyAS400;UID=abc;";Initial
Catalog=S10497HM")

The problem is showing up at the "DSN" portion of the code.

Does anyone know what is causing this? Thanks!
 
* CBT said:
I am trying to connect to an AS400. I can see the files in my Data
Connections, but the following code is generating this message:
"Comma, ')', or a valid expression continuation expected". The code
is:

Dim objConnection As New OleDb.OleDbConnection( _
"Provider=MSDASQL.1;Persist Security Info=False;User ID=abc;Data
Source=MyAS400;Extended Properties="DSN=MyAS400;UID=abc;";Initial
Catalog=S10497HM")

The problem is showing up at the "DSN" portion of the code.

Replace all double quotes inside the string with two successive double
quotes:

\\\
Dim s As String = "He said: ""Hello World!"""
///
 
.. . .

Quote characters in quoted string literals need to be "escaped",
by doubling them up, as in

Dim objConnection As New OleDb.OleDbConnection( _
"Provider=MSDASQL.1;Persist Security Info=False;" _
& "User ID=abc;Data Source=MyAS400;" _
& "Extended Properties=""DSN=MyAS400;UID=abc;"";" _
& "Initial Catalog=S10497HM" _
)

(additional lines breaks for clarity only).

HTH,
Phill W.
 
Back
Top