Hi,
I am using following connection string in my asp.net web.config:
[Less than symbol] add name="FMMConnectionString" connectionString="Data Source=xxxxxxxxx,1234;Initial Catalog=Test1Db;User Id=Rajeev;Password=xxxxxxxxxxxxx;" providerName="System.Data.SqlClient" [Slash][Greater than symbol]
The database is on remote database server. The sql user/ developer 'Rajeev' is deliberately given restricted permissions (to protect our schema) using following sql commands:
GRANT ALTER,EXECUTE, SELECT,INSERT,UPDATE,DELETE ON SCHEMA ::dbo TO Rajeev
DENY VIEW DEFINITION ON SCHEMA::dbo TO Rajeev;
GRANT CREATE PROCEDURE TO Rajeev;
GRANT CREATE FUNCTION TO Rajeev;
DENY ALTER ON SCHEMA::dbo TO Rajeev; -- To disallow Rajeev to create objects on dbo schema but only create in Rajeev schema while still being able to select, insert, execute on dbo schema.
The above connection string works perfectly fine when used from Visual Studio> Server Explorer. I am able to execute following sql queries without issues. Same is true when using SQL Server Management Studio using Rajeev credentials.
select top 100 * from XYZEmployees
execute usp_GetMMBSchemeDetails '1'
The error I get in web page is following:
The stored procedure 'usp_GetMMBSchemeDetails' doesn't exist.
When I ran code using breakpoints to see what is happening, I see that when connection object is being instantiated, the connection state is being closed with following error:
at System.Data.SqlClient.SqlConnection.GetOpenConnection()
at System.Data.SqlClient.SqlConnection.get_ServerVersion()
I turned off my firewall to see if it was blocking but it did not help. I tried using Visual Studio 2012 as well as Visual Studio 2013 but same issue showed up.
Kindly let me know why I am able to execute sql queries from SSMS and Visual Studio's Server Explorer but not from application code. Is there something that needs to be enabled on remote database server so that the queries can run from code? I like to create
more users like Rajeev with restricted permissions to develop my application. So kindly provide a solution if you know.
Thanks,
Pullet