Well coming to my issue
I planned to test my connection using " State " member of connection class . so i have written
Logic :
Declarations: using System.Data.OleDb;
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection("provider=SqlOleDb;Integrated Security =SSPI;Database=Master");
con.Open();
MessageBox.Show(con.State.ToString());
con.Close();
MessageBox.Show(con.State.ToString());
}
under button when i click it i should tell me the status of connection :)
But i am facing errors like : Invalid authorization specification
Invalid connection string attribute
some other time :[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
I installed SQL server 2008 on my local machine :)
Any ideas about this :)
Thank you


VulpesRank #55 · 29.2K reputationPosted Feb 26, 2013, 10:42 AM EST
http://www.connectionstrings.com/sql-server-2008#net-framework-data-provider-for-ole-db
SUNIL GUTTARank #1,831 · 810 reputationPosted Feb 26, 2013, 10:59 PM EST
I have tried using sql client but i am getting diff diff error's
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
what to do ? server is not recognized :(
i used : using System.Data.SqlClient;
SqlConnection con = new SqlConnection("Integrated Security=True;Database=SunilDB");
In Sql server configuration manager logged in with windows authentication & made SQL SERVER BROWSER ,sql integration services& SQL SERVER(SUNIL SERVER) running :) remaining all stopped not able to start also them :( checked all pipes made them enable :)
Plz help me out .
But this is when i removed con.open() in above program then i am getting output like 2 message boxes saying connection closed .
Thank you
Prabhakar Reddy101 reputationPosted Feb 27, 2013, 8:09 PM EST
i understood ur problem,
the problem is very simple, you just upload ur database to server and give server path to there, right now u gave local path (i think SunilDB is local database path).
** change ur database path appropriately means if u r runing locally give local path otherwise give server path.
SUNIL GUTTARank #1,831 · 810 reputationPosted Feb 28, 2013, 2:27 AM EST
As you said i tried already dude . check above connection string mentioned local database name only .. is there any corrections i need to do ? i am getting same error as mentioned above
Prabhakar Reddy101 reputationPosted Feb 28, 2013, 2:33 AM EST
add db path on web.config
Ex:
web.config:
Call that connection string on webpage
SqlConnection con=NewSqlConnection(ConfigurationManager.ConnectionStrings("NewsDBConnectionString").ConnectionString)
Rimi Jain10 reputationPosted Feb 28, 2013, 2:36 AM EST
Remove "Integrated Security=True" and try again.
Rimi
SUNIL GUTTARank #1,831 · 810 reputationPosted Feb 28, 2013, 2:55 AM EST
SUNIL GUTTARank #1,831 · 810 reputationPosted Feb 28, 2013, 2:57 AM EST
I'M confused Are saying about configuration files :) i am beginner in connection string so can you please be more elobarate :(
Sorry to insist you & plz
SUNIL GUTTARank #1,831 · 810 reputationPosted Feb 28, 2013, 10:27 PM EST
Here goes the answer for my silly query :)
Error i discussed : A network-related or instance-specific error occurred while establishing a connection to SQL Server.
Remedy: OleDbConnection con = new OleDbConnection("provider=SqlOleDb;Integrated Security =SSPI;Database=Master;Data Source=LION-PC//sunilserver");
Note: ACTUALLY i used single back slash but as single '/' not supported as u know lol i don't know that when used '//' works fine like above & must mention data source name it can't be optional although it local sys :)
Instance error occurs jut becoz when we install visual studio first later sql server 2008 it will cause some trouble shooting problems like this :) like this this bug fixed
Thank you very much to my Sir clarified in one shot :)