Database Server - SQL Access: Cannot connect from code but from SSMS

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

Thanks Everyone for your insights :) 
RSingh, Your approach works when using SSMS, not when called from application code (example: asp.net code-behind page calling a stored proc using connection object).
My requirement is, I only wanted developer to do front end programming without having the ability to look at backend sql objects definitions. He/she can call the sql objects in the program as needed. 
I am able to finally solve this requirement by following approach. Hope it helps others. 
1. Right-click Rajeev user in Database> Security>Users and unselect 'dbowner' from 'General' tab> 'Database Role Membership' section even though Default Schema shows up as Rajeev schema. Now, this user can't do anything on dbo schema of database
(as well as in any other user's schema in this database).
2. Ran above commands but excluded following command which was identified as root-cause.
DENY VIEW DEFINITION ON SCHEMA::dbo TO Rajeev;
3. Now ran a script that denies 'view definition' of dbo schema's tables. It loops through all tables and denies 'view definition' on each table. Adapted the script of http://blog.extreme-advice.com/2013/01/23/grant-view-defination-permission-to-all-stored-procedures-in-sql-server/.
Now, the user Rajeev can execute dbo schema objects both from SSMS as well as from application code.
4. DENY EXECUTE, SELECT ON SCHEMA::INFORMATION_SCHEMA TO Rajeev; -- Restricts Rajeev from executing INFORMATION_SCHEMA objects seen in SSMS.
However one remaining open item is, I could not hide the system objects (which are part of sys schema) in SSMS. Ideally, I do not want Rajeev to execute the 'system views', 'system stored procedures', etc. When I execute same command (below command), it
runs without errors but does not apply this restriction.
DENY EXECUTE, SELECT ON SCHEMA::sys TO Rajeev;
If you know the reason why it is happening like this, please kindly share.
Cheers,
Pullet
Cheers | Pullet

Similar Messages

  • SQL Server Configuration Manager – Cannot connect to WMI provider – Invalid class [0x80041010]

    look at this post am getting the same
    http://social.msdn.microsoft.com/Forums/en-US/sqlkjmanageability/thread/4c8ca86c-105f-4f0a-ac18-6e33dda2bc46
    but when I tried the solution given there , It is not working
    the error I am getting is mofcomp is not recognized as internal or external command
    I tried in  C:\program files\Microsoft sql server\90\shared  and in Windows\system32
    I am getting the same error

    Hi sql393,
    Cannot connect to WMI provider. You do not have permission or the server is unreachable. Note that you can only manage SQL Server 2005 servers with SQL Server Configuration Manager. Invalid class [0x80041010].
    The solution is to go to a command prompt and then run mofcomp.
     C:\Program Files\Microsoft SQL Server\90\Shared>mofcomp "C:\Program Files\Microsoft SQL Server\90\Shared\sqlmgmproviderxpsp2up.mof"
    For more information, please refer to
    http://blogs.msdn.com/b/echarran/archive/2006/01/03/509061.aspx
    http://msmvps.com/blogs/martinpoon/archive/2009/11/27/sql-server-configuration-manager-cannot-connect-to-wmi-provider-invalid-class-0x80041010.aspx.
    Thanks,
    Maggie
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.

  • Cannot connect from dreamweaver cs5.5 to mysql using the mysql connection wizard

    Cannot connect from dreamweaver cs5.5 to mysql using the mysql connection wizard error Http error 403 or 500 internal server error. I am using ubuntu mysql.
    a manual php script work fine
    <?php
    // open connection to mysql server
    $dbc = mysql_connect('localhost','root','password');
    if (!$dbc) {
                die('Not Connected' . mysql_error ());
    //select database
    $db_selected = mysql_select_db ("msinventory",$dbc);
    if (!$db_selected)
            die('Cannot Connect' . mysql_error());
    echo "TEST DONE1";
    ?>
    but the database connection wizard fails with http error 403 or 500
    i also use the HeidiSQL client and it works, the only problem is in dreamweaver.

    OK.  Did you really mean to ask this question on a ColdFusion forum, if it's DreamWeaver you're having problems with?  You're probably better off raising this on a DreamWeaver forum.  "Using the correct tool for the job" 'n'all.
    Adam

  • SQL Developer-Cannot Connect

    Hi, I have the same problem as the person who posted the question
    The history is i already have oracle 10g express edition installed on my system but with it I cannot create tables or execute DML or DDL commands so I downloaded SQL developer .
    When it came to the connection I wanted to fill in the Hostname , Port and SID in that order it gave me that same error "The network adapter could not establish connection ", and to fill in those spaces I used the link I saw when opening the Human Resources schema in the express edition(The schema came in the express edition and I used it to learn the SELECT statement). so i tried to use that address and it came in this format :- http://127.0.0.1:8080/apex/f?p=4500:1000:3171371893604961
    And since SQL told me to fill those parameters as Hostname:Port:SID I felt the use of the last 3 digits i.e 4500:1000:3171371893604961 would have worked but that is what is giving me the error.
    I would appreciate the help. Thank you

    This post has been branched off from and refers to
    SQL Developer-Cannot Connect
    @user 867945,
    Please do not resurrect long dead threads.
    It is poor forum etiquette.
    Post your own new inquiry so that anyone that responds is answering YOU.
    Feel free to provide a reference link to any discussion, anywhere, that may be somehow similar.

  • Safari can't find server...cannot connect to internet

    I Keep getting "Safari can't Rind Server" and I cannot connect to the Internet.  any suggestions?

    Hey Dusty4961,
    I understand that you are having issues with connecting to the internet from your iMac. Here is an article that will help you troubleshoot these issues:
    About Wireless Diagnostics - Apple Support
    http://support.apple.com/en-la/HT202663
    Thanks for using the Apple Support Communities. Have a good one!
    -Braden

  • TS4502 why i cannot connect from computer to my ipad

    why i cannot connect from computer to my ipad

    you need to install latests version of itunes on the computer

  • Cannot connect from Mac Pro late 2013 to Macbook Pro

    Cannot connect from Mac Pro late 2013 to Macbook Pro . I have tried via ethernet and wifi. I can connect from the MBP to the Mac Pro but not vice versa. I have tried to connect to other MBP's on the same network with no luck. I try and connect as a registered user, as I usually do, with no luck. When I enter the Username and then Password the box vibrates as if the details are incorrect, they are not however.
    Thanks in advance
    Jeff

    It is 'just not working' again.
    To answer you question. Other sharing services work. I can connect as a guest. I can share screens. I cannot air drop.
    I cannot connect either way now i.e. from Mac Pro to MBP and vice versa.
    I cannot connect to my wife MBP either. My wife cannot connect to my Mac Pro.
    It neither works with wifi or ethernet cable.
    I can connect to my Time Capsule directly and Time Machine backups are working.
    The passwords are 100% correct.
    The Mac Pro is a late 2013. Does anyone else have a similar problem? I have never suffered this one before. Seriously effecting my workflow
    Thanks

  • Cannot connect to facebook but have no problem connecting to other websites

    I cannot connect to facebook but have not problem connecting to other website? How can I change check this problem?

    Andrew Heckler
    Re: Unable to access Facebook from ANY browser on my Mac (suddenly) 
    Dec 21, 2012 7:00 PM (in response to dpman2008)
    I had the same problem, and I just fixed it. See this thread-https://discussions.apple.com/thread/4612888?start=0&tstart=0
    Let me know if this works!
    Klickut: This solved my problem.  I'm now left wondering how the hosts file became corupt or modified that blocked Facebook only? 

  • I have I pad 2 and every time I try and get on message or FaceTime it says cannot connect check internet but I have full signal I have tried everything but no luck

    I have I pad 2 and every time I try and get on message or FaceTime it says cannot connect check internet but I have full signal I have tried everything but no luck

    Try this:
    Settings>General>Date & Time>Set Automatically>On

  • I cannot update ios as it says itunes cannot connect to internet, but it is

    Hi everybody, please help me. I've been trying to update my ipad for ages. When i click update it says itunes cannot connect to internet, but it is and it works for iphone and ipod, it's just the ipad. tried with security settings as well, but it doesn't work. did the connectivity test and it says itunes cannot connect to internet...it is connected

    If you have an iPad 1, the max iOS is 5.1.1. For newer iPads, the current iOS is 6.1.3. The Settings>General>Software Update only appears if you have iOS 5.0 or higher currently installed.
    iOS 5: Updating your device to iOS 5 or Later
    http://support.apple.com/kb/HT4972
    How to install iOS 6
    http://www.macworld.com/article/2010061/hands-on-with-ios-6-installation.html
    iOS: How to update your iPhone, iPad, or iPod touch
    http://support.apple.com/kb/HT4623
    If you are currently running an iOS lower than 5.0, connect the iPad to the computer, open iTunes. Then select the iPad under the Devices heading on the left, click on the Summary tab and then click on Check for Update.
    Tip - If connected to your computer, you may need to disable your firewall and anitvirus software temporarily.  Then download and install the iOS update. Be sure and backup your iPad before the iOS update. After you update an iPad (except iPad 1) to iOS 6.x, the next update can be installed via wifi (i.e., not connected to your computer).
    Tip 2 - If you're updating via wifi, place your iPad close to your router to preclude getting a corrupted download.
     Cheers, Tom

  • IPhone 4 cannot connect to computer but will charge through wall socket. Does anybody know how to fix it?

    iPhone 4 cannot connect to computer but will charge through wall socket. Does anybody know how to fix it? Can you please reply fast as i need to use my iPhone soon.

    See either http://support.apple.com/kb/TS1538 (windows) or http://support.apple.com/kb/TS1591 (mac).

  • Cannot connect from iMac to Windows Home Server 2011 shares

    Hi guys,
    I am having dificulties connecting from iMac to Windows Home Server 2011 shares.
    First of all it takes so long time to discover the share in iMac, which it's called "mediaserver". After finding it i cannot connect and gives "Connection Failed: message. If i choose "Connect As.." option i wait some time and then pops out with an error: "There was a problem connecting to the server "mediaserver". The server may not exist or it is unavailable at this time. Check the server name or IP address, check your network connection, and then try again."
    If i try from Finder -> Go -> Connect to Server ... write in Server Address : smb://mediaserver it fails. But if i write the IP address, like: smb://192.168.1.42 it works after couple of tries. If i try now to Make an Alias for the share i get "The operation can't be completed. An unexpected error occurred (eror code -8060)."
    Has anyone experienced these problems ? I have updated to Mac OS X version 10.7.3. Could that be the problem ?
    Any help will be much appreciated.
    Thank you in advance,
    Simi

    You need to reinstall the updated WHS connector for Mac.  You should then be able to access your shares on WHS 2011. 
    The problem I'm having is I can't get Time Capsule to recognize the WHS 2011 mapped folders that show up on the desktop as a drive, so Backup won't work.

  • Can Connect via Database Control but Cannot Connect from Enterprise Manager

    Hi experts,
    This is a 10g database on a Windows server.
    when I remote into the server:
    - I CAN connect via the web-based Database Control
    - I CANNOT connect to any db/instance via regular Ent Mgr - get the ugly "ORA-12154 TNS: could not resolve the connect identifier specified" error.
    I thought both tools used the same connection files (tnsnames, listerner etc), but maybe not.
    When db control connects, but Enterprise Manager cannot, what should I check to find the problem?
    Thank you.
    John

    Thanks madrid.
    I eventually got it to work by changing the tnsnames.ora in the client_1 folder
    This is the original:
    FS9ENFP1 =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = PNCLAFDB)(PORT = 1521))
    (CONNECT_DATA =
    (SID = FS9ENFP1)
    (SERVER = DEDICATED)
    ORCL=
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = PNCLAFDB)(PORT = 1521))
    (CONNECT_DATA =
    (SID = orcl)
    (SERVER = DEDICATED)
    EXTPROC_CONNECTION_DATA =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    (CONNECT_DATA =
    (SID = PLSExtProc)
    (PRESENTATION = RO)
    I removed the EXTPROC entry and added entries for the ORCL and FS9ENFP1 databases, specifying server_database like this:
    FS9ENFP1_PNCLAFDB =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = PNCLAFDB)(PORT = 1521))
    (CONNECT_DATA =
    (SID = FS9ENFP1)
    (SERVER = DEDICATED)
    Not really sure WHY it is necessary to list an instance twice, once without server name and another with server name... but EM is able to connect now. I simply modeled tnsnames after another Oracle server where EM was able to connect.
    John

  • Brazil Preview - Create Sql Database Server - Argument 'adminPassword' cannot be empty

    While trying to create a new Sql Database Server in Brazil (Preview) using Azure Portal the following error occurs: "Argument 'adminPassword' cannot be empty".
    Anyone is having the same error? I have fulfilled al the form inputs: LOGIN NAME, PASSWORD, CONFIRM PASSWORD AND REGION.
    Any help would be appreciated.

    I can't believe this issue was because of using firefox. I tried with chrome (unintentionally) and it works.

  • BPC 7.0 Server Installation Problem - Cannot connect to reporting services

    I am upgrading from 5.1 to 7.0 version for SAP BPC.  Everything went smooth on the development server (single instance installation including SQL Server 2005 developers edition 32bit, web, reporting and application services on the same server). I tried to repeat the same process on the test server, and the installation went off the rails.  I started with clean installations of SQL Server 2005 on both servers.
    When I try to install the BPC server software, I get to the point of access to the report server, and everything stops. I get the following message: Cannot connect to reporting services.  I have verified the reporting server name, and I have verified that the server name is correct in the installation panel. I have also verified that the reporting server is configured, started, and that there are no errors.
    Any advice?

    Hi Sorin,
    Thanks for the tip, but this was not the case.  The problem was solved by re-loading the OS. Using Windows Server 2003 gave an issue during the re-installation of the SQL Server database. The problem was in the installation itself. After a clean install of both the OS and SQL Server, then SAP BPC 7 worked. The installation does require a number of tweaks, particularly, in my case, the entire Management console must be configured, even if not being used.
    This problem is now solved.
    J.

Maybe you are looking for

  • I need to put a web page in its own folder

    I'm designing a site in Muse and a couple of pages have to be stand-alone and accessed by the user typing the address directly like, www.site.com/info So, I need to put a page names index.htm in the folder info. How can I do this with? The stand-alon

  • Illustrator cs4 slowing down

    I have just recently upgraded to adobe cs4 from cs2 and am wondering why now when I copy a file from Illustrator and click on my photoshop it takes a few minutes for photoshop to load up when it is already loaded and I can do nothing but surf the int

  • Private Browsing Autofill (password saver) in Safari

    I'm posting this because we had a dickens of a time locating the answer in ASC, and the iPad2 User Guide does not contain this important proviso. One day my wife had to change up a password to login to her highly secure network.  Going into Safari, s

  • Migration Contact Center Express 4.5 to Contact Center Express 8.5

    Hi Everyone I plan to migrate a Contact Center Express 4.5 to Contact Center Express 8.5, I' m not sure if the database will be restored in the new release, so I was searching information about the database, but I coudn't find information about that,

  • IPhone SDK Multi-Touch Bug?

    Hi, I'm trying to handle multi-touch events and this is the bug I'm seeing ( using SDK beta 4 ): The first touch I make has a valid position ( using locationInView instance method ). However, any touches made while the first touch is being held down