c# - Local database: "A network-related or instance-specific error occurred while establishing a connection to SQL Server." -


i'm having problems setting super-simple sql database project in visual studio 2010.

upon opening connection local sql database following 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: sql network interfaces, error: 26 - error locating server/instance specified)

all google searching comes network related solutions, checking firewall settings or configuring remote connections. local sdf file.

i've literally created new blank wpf project. right clicked , "add new item" chosen "local database" clicked next produce database1.sdf. can access in server view in vs2010, add tables etc, , crucially, connection string.

i create connection using said string:

using system.data.sqlclient;  namespace sqltest {      <summary>      interaction logic mainwindow.xaml      </summary>     public partial class mainwindow : window     {         public mainwindow()         {             initializecomponent();              try             {                 sqlconnection conn = new sqlconnection(@"data source=d:\projects\sqltest\sqltest\database1.sdf");                  conn.open();                  messagebox.show(conn.serverversion);             }             catch (sqlexception e)             {                 messagebox.show(e.message);             }         }     } } 

but fails above error on "conn.open()". i'm sure i've created local databases before, , googling comes people actual network problems. nothing local databases.

i'm @ loss, wondering if following these steps results in same thing other people? i've had colleague same thing , same error occurs.

as concluded connection string trying connect sql ce database. use sqlconnection that.

instead use sqlceconnection adding reference system.data.sqlserverce.dll


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -