c# - attach standard database with connection string -


i use sql server r2 2008 standard , c#. use connection string:

<add name="conn" connectionstring="metadata=res://*/dbl.model.csdl|res://*/dbl.model.ssdl|res://*/dbl.model.msl;provider=system.data.sqlclient;provider connection string=&quot;data source=.;initial catalog=dbfactor1;integrated security=true;multipleactiveresultsets=true&quot;" providername="system.data.entityclient" /> 

but want attach database file in connection string , use connection string:

<add name="conn" connectionstring="metadata=res://*/dbl.model.csdl|res://*/dbl.model.ssdl|res://*/dbl.model.msl;provider=system.data.sqlclient;provider connection string=&quot;data source=.\sqlexpress;attachdbfilename=|datadirectory|\db\program1.mdf;initial catalog=program1;integrated security=true;user instance=true;multipleactiveresultsets=true&quot;" providername="system.data.entityclient" /> 

but connection string sql server express, use data source=. , error:

the underlying provider failed on open.

please me use connection string , attach database.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -