Pergunta

I am trying to add an control to my page. I am following the wizard. Step 1, I select my connection string. The connection works, no error messages. Step 2, I choose "Specify a custom SQL statement or stored Procedure" radio button. Step 3, in the "SELECT" tab I click the "Stored Prodedure" radio button, then select the stored procedure I would like to use. I take this as confirmation that the connection string is working. Step 4, I press the "Test Query" button.

A pop up appears with the message "There was an error executing the query. Please check the syntax of the command and if present, the types and values of the parameters and ensure they are correct. Could not find stored procedure .

I've tested the procedure in SSMS, and it works. I took the query string that is in the stored procedure and changed the radio from Step 3 to "SQL Statement" and pasted the string into the box. The statement worked fine.

I also changed the permissions for the login specified in the connection string to the same permissions I have on the server. (Full admin rights!) That did not correct the issue. I only found a few questions in the forums regarding this issue, and they all pointed to permission issues, but I have ruled that out as I set the permissions.

The Wizard can find the procedure when I am walking through the Wizard, but it can't find it when I test.

I hope someone can point me in the right direction... Thanks!

* EDIT * Just to expand on the @BlackjacketMack's answer:

When I use the wizard to create the SqlDataSource, and select the Stored Procedure from the the list, it appears that VS is defaulting to the dbo schema at runtime, even though it displays all the sprocs in each schema. (I verified this by changing the schema the sproc was on to dbo and testing it. The results were returned with no errors.) Within the wizard, I do not see any options to change the schema. If I click the "SQL Statement" radio button and type EXECUTE [APP001].[MyStoredProcedure], it works perfectly. I did try the GRANT EXECUTE as @otaku recommended, but that did not work. I also changed the default schema for the user specified in the connection string to [APP001] to no avail. So this appears to be an issue when using the dropdowns in the wizard. Manually entering the data so that the schema can be fully qualified did the trick!

Foi útil?

Solução 2

Qualify your procedure with the schema If the proc has a schema 'APP001' as you indicated in a comment, make sure the Sql being passed looks something like EXEC APP001.YourStoredProcedureName.

Use a profiler! One great way to approach this problem is run a profiler on your SQL...either the MS Profiler, or we use http://anjlab.com/en/projects/opensource/sqlprofiler which used to be free. Basically, you'll see exactly what SQL your application is sending and who the login they're sending it as.

If you gave yourself admin permissions as you indicated, I wouldn't define too many object specific permissions simply because they tend to go unmaintained.

Outras dicas

Make sure the application that you are running have the appropriate grant execute on the database objects. Sometimes they are tied to a database role such as below where the stored procedure need to have the execute permission:

GRANT EXECUTE ON ][dbo].[MyStoreProc] TO U_ExecuteProcs

I think defining the execution context within your stored procedure will resolve the issue , Here is the link:

http://technet.microsoft.com/en-us/library/ms188354.aspx

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top