[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

Why is this happening?

I am performing a simple display of events. I dont want to do anything more but display them.

So i need a user and i am using a

user = CStaffUser.GetDefaultStaffUser();

it works everywhere else except in this one section where this pops up.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi Tim, The error message

Hi Tim,

The error message you see is a connection issue to your SQL server. Here is a few things I would check.

Did you use ASI.iBO.iboAdmin.InitializeSystem() or ASI.iBO.iboAdmin.InitializeSystem(SomeConnectionInTheConnectionsStringSection)? The iBOs do need to be initialized to get all of the paramter settings. If you use the ASI.iBO.iboAdmin.InitializeSystem()  method, make sure you have the DataSource.iMIS.Connection connection string in your web.config or app.config file depending on your application. You only need to initialize these settings once on your application. See below for an example on the connection string. On a web application, I found the best place to put this string is in the global.asa file under the application_start subroutine.

Is TCP and Named Pipes enabled SQL server configuration? Does the firewall on the server hosting the SQL database have TCP 1433 and UDP 1434 on the SQL server open to your application. Is the SQL server browser service running on the server hosting the SQL instance. If not make sure it is running.

Are you using SQL server express as your database server. If you are, then you need to make sure you have the \SQLEXPRESS at the end of your server to differentiate the instance of SQL server.

I hope this helps,

Sean Irish
Database Specialists
Assocation of Surgical Technologists

---- Connection String Example ----

<code>

  <connectionStrings>
       <add name="DataSource.iMIS.Connection" connectionString="Data Source=some_server;User ID=sa;Password=somepassword;Initial Catalog=Your_iMIS_Database"/>
       <add name="iMIS_SQL_SERVER_EXPRESS" connectionString="Data Source=some_server\SQLEXPRESS;User ID=sa;Password=somepassword;Initial Catalog=Your_iMIS_Database"/>
  </connectionStrings>

</code>

Same Issue - No Resolution

I am receiving the same error when I call the "Asi.Security.SecurityContext.ImpersonateAnonymous()" method from custom code. The error does not occur when I call the Asi.iBO.IBOAdmin.InitializeSystem() call. The latter call appears to work (an SQL Profiler show activity on the DB).

I also do not get the error when connecting to the database from a direct SQLClient connection using the same connection string used for iMIS in my application calling ImpersonateAnonymous, even when I add such to the same custom code that fails with the ImpersonateAnonymous call. I can also see the target database from SQL Server Studio.

The problem seems to be specifically with this ImpersonateAnonymous() call. What connection string is the "ImpersonateAnonymous" call using to connect to the DB?

 

Hi Mark, I did  a little

Hi Mark,

I did  a little poking around and it looks like ImpersonateAnyonymous() is using the DataSource.iMIS.Connection connection. You have to use the DataSource.iMIS.Connection connection string when you are using anything in the ASI.dll. It does not look at any other connection strings.

Thanks,

 

Sean Irish
Database Specialist
Association of Surgical Technologists

Must Be Something Else...

Ok - the DataSource.iMIS.Connection connection string is already set and works. For example, the iboAdmin.InitializeSystem() method finds it and uses it successfully before the ImpersonateAnonymous method is called.

Another piece of the puzzle here is that all of this was working last week. I had one VM running a web app and using the custom code which makes the ImpersonateAnonymous call and includes the DataSource.iMIS.Connection connection string pointing to another VM with the iMIS database. It all worked great. However, since then, I had to clone the VM with the web app. The new VM cannot seem to find the database server when called from ImpersonateAnonymous.

Could be some kind of network protocol issue. Does ImpersonateAnonymous do something strange with network protocol?

Hi Mark, As far as I know,

Hi Mark,

As far as I know, it does not do anything with the network protocol. Here is something for you to try. See what happens when you reference ASI.Data.DataServer.ConnectionString. It should return the DataSource.iMIS.Connection connection string. If it returns nothing, then the DataSource.iMIS.Connection failed to load. If it returns something old, then you might have to recycle your application pool. The iboAdmin.InitializeSystem() only initializes ASI.iBO.dll. So I would assume that it does work. You also maybe working with some old object in memory that just need to be recycled.

Thanks,

 

Sean Irish
Database Specialist
Association of Surgical Technologists

Interesting...

Actually I already tried looking at "ASI.Data.DataServer.ConnectionString"  in the watch windowright before the ImpersonateAnonymous call. It failed with a timeout error in the watch window. Not sure what that means except that the call to the Data.DataServer must be trying to reach it also. The entire object model outside of iBO seems to be unable to find the dataserver!

My issue was resolved with

My issue was resolved with putting the right connection details in.

It just seemed weird to me i had to fix it since it was barely touched but i remember now that i have been playing around with encryption of the web.config file connection strings and i must of entered in part of the connection to iMIS wrong.