Question:
ASP.NET 2.0 c# program is not connect to sql server 2005?
veera
2007-06-13 09:05:55 UTC
This is the program

protected void Button1_Click(object sender, EventArgs e)
{

string isuruConnectionString = "Data source=HOME-D476A40965/SQLEXPRESS;Initial Catalog=isuru; Integrated Security=True";


string sql = "INSERT INTO tan(name,passwd)value('333','444')";
SqlConnection con = new SqlConnection(isuruConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand(sql, con);


con.Open() line is highlighted and display this error.

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

But I was alow remote connection to sql server using "sql server serface aria configuration"option.

What is the problem(s)?.
Three answers:
2007-06-13 09:08:31 UTC
there goes +2 points
2007-06-13 09:48:29 UTC
The first question should be whether you are connecting to SQL Server on a remote machine or on the same machine.



If on the same machine,

Then you should configure the connection to be "Shared Memory" - Then everything will "just work" unless you have a typo somewhere.



If you configure Named Pipes or TCP/IP, then you likely will need to make sure your security is right.



Connecting to a database on another machine is a bit more complex because you connect using a remote connection. Your sql connection string specifies it's using Integrated Security. The only way that can really work is if both machines are part of the same Domain and the security context of your connection string is a Domain User account.



Lastly, I'm not sure what you are really trying to do... It looks like you're inserting a username/password credential pair into a table? It's possible but a somewhat odd thing to do if your application uses integrated security... The purpose of something like this just wouldn't be for the application itself generally.
pfautz
2016-10-09 07:09:47 UTC
sq. Server databases won't be able to be related to by utilizing their filename. You hook up with their provider engaged on the server, utilizing they server or occasion call. provider=SQLOLEDB;driving force={sq. Server};Server=YOURSERVERNAME;database=Y...


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...