markrendle / Simple.Data

A light-weight, dynamic data access component for C# 4.0
MIT License
1.33k stars 302 forks source link

error using named connection and SQL Express #390

Open GusBeare opened 8 years ago

GusBeare commented 8 years ago

I am using SImple.Data locally and have this code:

var db = Database.OpenNamedConnection("q2_admin"); //var db = Database.Open();

It works fine in my dev environment where I am using a developer version of SQL server 2012.

However when my colleague runs the code on his box with SQL Express 2012 he gets this error:

[Error] Specified argument was out of the range of valid values. Parameter name: connectionName

If I switch to using the default connection it works fine.

Is SQL Express supported? Or is this a bug?

WayneHiller commented 8 years ago

I use SQL Server 2012 Enterprise, Standard and Express no differences in connecting. Make sure a connection section exists in the config with that exact name on all the computers using your code.

GusBeare commented 8 years ago

Thanks Wayne. My colleague has the same code base and web.config as myself. The connection strings are in his web.config. I am wondering if there is an issue with underscores in the connection string name? I will check out this theory and report back.

GusBeare commented 8 years ago

Yes, I was correct. Having an underscore in the connection name causes the error in SQL Express 2012. Removing the underscore fixed the problem. Is this a Simple.Data issue or a SQL server Express one?

WayneHiller commented 8 years ago

Interesting.I have never tried using a leading underscore in the connection name. I don't see how it could be Simple.data as ut just uses the SqlConnection object.