asp.net - Connect To Local Database File (.mdf) -


i trying connect local database file (.mdf) located in app_data folder asp.net dev project. gives me exception. have missed ?

web.config:

<connectionstrings >     <add       name="testlocaldb"       connectionstring="data source=.\sqlexpress;attachdbfilename=|datadirectory|db.mdf;integrated security=true;connect timeout=30"       providername="system.data.sqlclient"    />   </connectionstrings> 

code-behind:

string con = configurationmanager.connectionstrings["testlocaldb"].connectionstring;             sqlconnection connection = new sqlconnection(con);             connection.open(); //here gives exception 

exception:

a network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections. (provider: sql network interfaces, error: 26 - error locating server/instance specified)

check whether have default instance of sqlexpress installed or not. otherwise need have instance name of sql server.

for more information see following link.

http://technet.microsoft.com/en-us/library/ms143744(v=sql.90).aspx


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -