I would like to use Dapper to establish a link for my WebApi. But I got this error below:
The value's length for key 'data source' exceeds it's limit of '128'
The cause of this error is this line:
IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
Below is my connection string in the Web.config:
<connectionStrings> <add name="DefaultConnection" connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=myService)));User ID=userId;Password=password" providerName="System.Data.OracleClient"/> </connectionStrings>
I know there is a way to solve this by using Oracle.ManagedDataAccess but I would really like to try using Dapper. Is there a way where I can solve the limit issue?
I have looked at this solution The value's length for key 'data source' exceeds it's limit of '128' but is there a simpler way without involving Oracle.ManagedDataAccess? Thanks
I have changed the SqlConnection to OracleConnection and it solved the issue.
using System.Data.OracleClient; .... IDbConnection db = new OracleConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);