Pergunta

I am getting a strange behavior by TADOQuery component in Delphi 7 on Windows XP and Windows7 operating system. Following issue works fine on Windows7 oprating system, but it gives an error on XP operating system.

Let me explain the scenario, I have one TADOConnection component and two TADOQuery components. The TADOConnection component is having the value for ConnectionString property as follows:

ADOConnection1.ConnectionString := 'Provider = MSDASQL.1; Password = My Password; User ID = My User ID; Data Source = My Data Source';

I have already applied the role/granted permission to the User ID/Password which I am login to the application.

I have connected TADOConnection component to the TADOQuery components using Connection property.

When I execute the first sql then it works fine without any error, but when I execute the second sql that time I am getting following error on Windows XP operating system.

[Microsoft] [SQL Server Native Client 10.0] [SQL Server] The SELECT permission was denied on the object 'My Table Name', database 'My Database Name', schema 'dbo'

The same code if I execute on Windows7 oprating system it works fine without any error.

Could anybody put focus what could be missing or what could be the issue ?


I have added "Persist Security Info = False;" to a connection string as follows:

ADOConnection1.ConnectionString := 'Provider = MSDASQL.1; Persist Security Info = False; Password = My Password; User ID = My User ID; Data Source = My Data Source';

Now, whenever I execute the sql using TADOQuery component, I need to write following statement every time, even if I have already set the "Connection" property of TADOQuery at the beginning, still I need to set this property whenever I execute the sql.

ADOQuery1.Connection := ADOConnection1; 

But as I said, On Windows7 there is no need to change the "ConnectionString" property of TADOConnection component and no need to set the "Connection" property of any TADOQuery component.

Could anybody tell what exactly has to be done ?

If your application is too huge and lot of places coding changes are required, would anybody agree with that ? And what about testing efforts ? At all the places testing has to be done, right ?

So, I am still in search of proper solution. The question is still unanswered.

If anybody is having any clue or hint or proper solution that would be highly appreciated.

Foi útil?

Solução

  1. You have to check using SQL Profiler what is going on.
  2. My bet, ADO internally clones a connection or uses a connection pool, and next query pickups another physical connection. So, you are getting the error. To disable pooling add OLE DB Services=-4 to your connection string.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top