Sunday, March 11, 2012

"SQL Server does not exist or access denied"

Hi everyone!

I receive error "SQL Server does not exist or access denied" when I try to run a web application from my notebook. (when I'm working at home) The weird thing is that it occurs sporadically. Sometimes the connection works just fine. Other times it fails. When I run the application on my workstation at the office everything works perfectly.

Here's the stack trace:

[SqlException: SQL Server does not exist or access denied.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +484
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44
System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
Torris.Common.Data.GetDataSet(String ConnectionString, String sql) in c:\_\Manager\common\data.cs:14
Torris.Manager.Sizes.ListSizes() in C:\_\Manager\Sizes.ascx.cs:145
Torris.Manager.Sizes.Page_Load(Object sender, EventArgs e) in C:\_\Manager\Sizes.ascx.cs:77
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +731

-----------------

Of course, I make sure to change the connection strings in both environments.

Anyone have an idea of what I can look at to try to troubleshoot?

Thanks as always!!

Emi ^_^Hi Emi,

This is virtually always an access issue. How are you trying to connect to the db? IOW, what is your connection string? Are you sure your laptop is setup properly?

The other thing that strikes me is connection pooling. Do you do anything with pooling--change defaults, etc.--in the app?

Don|||Hi!

Thanks for responding. Still having the issue - it's so frustrating. I'm storing my connection string in the web.config which is then read and used in my Data.cs (database class)

Here's the connection string. In this case, the database is on the same machine as the web application. (similar to the how the client's production server is setup):


<add key="ConnectionString" value="server=MyComputerName;database=DatabaseName;uid=sa;pwd=NonBlankPassword;" />

An example of the actual data access - nothing complex here.


public static void ExecuteSql(string ConnectionString, string sql)
{
SqlConnection conn = new SqlConnection(ConnectionString);
SqlCommand cmd = new SqlCommand(sql,conn);
conn.Open();
cmd.ExecuteNonQuery();
cmd.Dispose();
conn.Close();
conn.Dispose();
}

Like I mentioned before, all works great on my workstation at the office. This might totally be a hardware - issue. Is there anything wrong with the above code that would cause any pooling problems.

Thanks again!

Emi ^_^|||Hi Emi,

Okay, assuming that your sa password in the actual connection string is right, everything else looks okay.

One thing to check is whether the SS2K server is set up to use SQL Server authentication rather than Windows integrated authentication only. You can do that in Enterprise Manager, right-clicking on the server, and selecting Properties. Under the Security tab make sure that "SQL Server and Windows" is selected.

Sigh. But never mind about that. This doesn't explain the sporadic nature of the error. There is something going on with the connection pool. You're not doing anything with the connection pool in your code, but it has a problem when it goes to the pool for a connection. Hmm. And it's happening deep within the .NET framework.

Have you monitored the pool to make sure that connections are still available? It's a weird error to get for a depleted pool, though.

This will take more research. Anyone else have any ideas?

Don

No comments:

Post a Comment