By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

Syntax Error?

P: n/a
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!
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
* CBT <aa*@aaa.com> scripsit:
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!"""
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

P: n/a
"CBT" <aa*@aaa.com> wrote in message
news:3k********************************@4ax.com...
.. . .

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.
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.