Reputation: 744
Given this entity model variable:
DataBaseEntities db = new DataBaseEntities ();
The below code can not use from db varibale connection string
SqlBulkCopy sbc = new SqlBulkCopy(db.Connection.ConnectionString);
Upvotes: 5
Views: 894
Reputation: 44605
try with this approach:
private string GetADOConnectionString()
{
var db = new DataBaseEntities();
EntityConnection ec = (EntityConnection)db.Connection;
return ec.StoreConnection.ConnectionString;
}
I've found this here: Getting SqlConnection from EntityConnection
also see here: EntityConnection.StoreConnection Property
Edit: of course this should be adapted and you should check for nulls or check before casting... it's just an example ;-)
Upvotes: 5
Reputation: 1206
Dim objEntities As New DBEntities
I have the connection string already set within .edmx file in my project.
Upvotes: -2