I have :
Dim con As New OleDbConnection(My.Resources.ConnectionString)
// Give exception = Format of the initialization string does not conform to specification starting at index 62.
When I substitute the actual value of the Resource, it give no exception :
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\rawData.xlsx;Extended Properties=""Excel 12.0 XML;""")
The value of ConnectionString in Resources :
<data name="ConnectionString" xml:space="preserve">
<value>Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\rawData.xlsx;Extended Properties=""Excel 12.0 XML;""</val开发者_StackOverflowue>
</data>
I don't understand why is this happening ?
I think this should have been replaced even before the compilation process..
Then why is it giving exception ?
In the configuration file, you have double quotation marks around the Extended Properties values. Try removing them so you have only one.
The reason why it is working with the literal, is that in VB .NET, a double quotation mark escapes the quotation mark character so it can be used in a string without terminating the string. This does not apply to XML.
You don't need the double quotes within the XML configuration file. It works fine when you substitute it, because ""
is correctly escaped to a single "
as it is a string literal.
精彩评论