c# - My database system cannot find the file specified in asp.net -


i trying retrieve data database following code:

public partial class populate : system.web.ui.page {     sqlconnection scon = new sqlconnection("data source = localhost; integrated security = true; initial catalog = populate");        protected void page_load(object sender, eventargs e) {              stringbuilder htmlstring = new stringbuilder();           if(!ispostback)         {             using (sqlcommand scmd = new sqlcommand())             {                 scmd.connection = scon;                 scmd.commandtype = commandtype.text;                 scmd.commandtext = "select * populate";                  scon.open();                  sqldatareader articlereader = scmd.executereader();                  htmlstring.append("'populate page:'");                                  if (articlereader.hasrows)                 {                     while (articlereader.read())                     {                         htmlstring.append(articlereader["datetime"]);                         htmlstring.append(articlereader["firstname"]);                         htmlstring.append(articlereader["lastname"]);                         htmlstring.append(articlereader["address"]);                         htmlstring.append(articlereader["details"]);                                            }                     populateplaceholder.controls.add(new literal { text = htmlstring.tostring() });                     articlereader.close();                     articlereader.dispose();                 }             }         }     } } 

it's throwing error:

the system cannot find file specified

i wondering if can show me error or guide me through debugging this. in advance.

(update): more specifically, scon.open() causing error:

message=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: named pipes provider, error: 40 - not open connection sql server)

this looks easy enough fix, i'm not database. appreciated.

i don't know sql server edition have installed, , called (as instance name) .....

go start > sql server > configuration tools > configuration manager; under sql server services, search sql server service - it's name??

enter image description here

if it's sql server (sqlexpress), means have express edition, instance name of sqlexpress - change connection string to:

data source=.\sqlexpress;initial catalog=populate;integrated security=true;  

if it's sql server (mssqlserver) should fine - have unnamed, default instance ....


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -