Hi,
Has somebody had a problem like this before?
Exception Details:System.Data.SqlClient.SqlException:An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by thefact that under the default settings SQL Server does not allow remoteconnections. (provider: Named Pipes Provider, error: 40 - Could notopen a connection to SQL Server)
That's part of the code:
SqlConnection con;
string sql;
SqlCommand cmd;
con=new SqlConnection("Data Source=elf/SQLEXPRESS;Initial Catalog=logos;Integrated Security=SSPI;");
sql="SELECT max(id_kandydat) from Kandydat";
con.Open();
cmd=new SqlCommand(sql,con);
int id = Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
SqlDataSource7.InsertCommand="INSERT INTO Kandydat_na_Kierunek(id_kandydat, id_kierunku, id_stan) VALUES ("+"'"+id+"'"+","+"'"+DropDownList1.SelectedValue+"'"+","+'1'+");";
I don't really get it. I'm nearly 100% sure that before some changes in my project this had worked perfectly. Does anybody have any idea how to make it work again? I would be very grateful for any help. And, yesy, I know it is quite common error, but proposed solution found didn't help.
Regards,
N.
Hi there,
In the SQL Management Studio, RightClick the SQL server instance, Choose
Properties, and under Select a Page list, click Connections. Now you should
see a checkbox labelled "Allow Remote Connections to This Server". Make sure
it is checked.
Check this link...
http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277
Hope this may helps you
Srinath
|||Hi,Thank you for your advice. The remote connection has already been set on.|||
Hi
From your description, it seems that you met error when you are trying to connect to your SQLServer,right?
First, you should make sure that if 1433 port has been enabled on your server, which is the default port for SQLServer remote connections.
And Generally, you can try the following ways to handle your problem.
1. Enable remote connections for SQL Server 2005 Express or SQL Server 2005 Developer Edition
2. Enable the SQL Server Browser service
3. Create exceptions in Windows Firewall
4. Create an exception for SQL Server 2005 in Windows Firewall
5. Create an exception for the SQL Server Browser service in Windows Firewall
More details for each step, you may see the following link:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277
Thanks.
Thank you. Remote connection for both servers are enabled (always have been). Windows Firewall is shut; no other firewall is running. It does in fact work locally.
Regards,
N.
|||
Hi,
Then, let's back to your connection string.
con=new SqlConnection("Data Source=elf/SQLEXPRESS;Initial Catalog=logos;Integrated Security=SSPI;");
It seems that you are connecting to a SQLExpress instance, Generally, if you are using SQLExpress, you should assign the AttachDBFilename, but not the InitialCatalog.
See the following sample string:
data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|YouDataBaseName.mdf;User Instance=true providerName="System.Data.SqlClient"
Thanks.