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="data source=.;initial catalog=dbfactor1;integrated security=true;multipleactiveresultsets=true"" 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="data source=.\sqlexpress;attachdbfilename=|datadirectory|\db\program1.mdf;initial catalog=program1;integrated security=true;user instance=true;multipleactiveresultsets=true"" 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
Post a Comment