I am working with C# windows application and I am facing a problem with OLEDB connection to SQL SERVER 2008 my code is too simple: I am trying to fill the datagridview from this query
string connString = "Provider=SQLOLEDB;Data Source=servername;Initial Catalog=DBname;Integrated Security=SSPI";
string query = "SELECT * FROM account";
//create an OleDbDataAdapter to execute the query
OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);
//create a command builder
OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(dAdapter);
//create a DataTable to hold the query results
DataTable dTable = new DataTable();
//fill the DataTable
dAdapter.Fill(dTable);
//the DataGridView
//DataGridView dgView = new DataGridView();
//BindingSource to sync DataTable and DataGridView
BindingSource bSource = new BindingSource();
//set the BindingSource DataSource
bSource.DataSource = dTable;
//set the DataGridView DataSource
dataGridView_FraudDetails.DataSource = bSource;
dAdapter.Update(dTable);
but I get the Following error in this line
//fill the DataTable
dAdapter.Fill(dTable);
"[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist o开发者_开发技巧r access denied." The code was running well , but when I uninstalled the server and reinstalled it again it gave me that error
I tried to turn off the firewall but it doesn't work any suggestion please
Are you using SQL Server Express? If so you need to make sure that it is configured to accept connections via either TCP/IP or named pipes. By default, SQL Server Express does not accecpt connections. See http://www.datamasker.com/SSE2005_NetworkCfg.htm (this page is specific to SQL Server 2005 but should apply to 2008 as well).
Go to SQL Server Configuration Manager (under All Programs > Microsoft SQL Server in start menu) and for your instance, make sure TCP/IP is enabled. It is disabled by default for a new install of SQL Server.
精彩评论