对于SQL Anywhere 17,我们需要在连接后进行autenticate,我将其设置为InitString,当我执行SAConnection.Connect
时这很有效。<add key="connectionString" value="UID=dba;PWD=***;Host=10.10.10.10:2638;InitString='SET TEMPORARY OPTION CONNECTION_AUTHENTICATION="Company=Quick Systems AS;Application=EQ Timing;Signature=xxxx...xxx"'"/>
但是当使用Entity Framework时,这个字符串已编码一次:
<add name="TimingConnection" connectionString="metadata=res://*/Timing.csdl|res://*/Timing.ssdl|res://*/Timing.msl;provider=Sap.Data.SQLAnywhere;provider connection string="UserID=dba;Password=sql;Host=10.10.10.10"" providerName="System.Data.EntityClient"/>
如何添加身份验证InitString
<add name="TimingConnection" connectionString="metadata=res://*/Timing.csdl|res://*/Timing.ssdl|res://*/Timing.msl;provider=Sap.Data.SQLAnywhere;provider connection string="UserID=dba;Password=sql;Host=10.10.10.10;InitString='SET TEMPORARY OPTION CONNECTION_AUTHENTICATION="Company=Quick Systems AS;Application=EQ Timing;Signature=xxx...xxx"'"" providerName="System.Data.EntityClient"/>
我得到的错误是初始化字符串的格式不符合从索引98开始的规范。
答案 0 :(得分:0)
要在连接字符串内部进行转义,我需要将"
加倍,因此它是""
<add name="TimingConnection" connectionString="metadata=res://*/Timing.csdl|res://*/Timing.ssdl|res://*/Timing.msl;provider=Sap.Data.SQLAnywhere;provider connection string="";UserID=dba;Password=sql;Host=10.10.10.10;InitString='SET TEMPORARY OPTION CONNECTION_AUTHENTICATION="Company=Quick Systems AS;Application=EQ Timing;Signature=xxx...xxx""'"" providerName="System.Data.EntityClient"/>