Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Incorrect syntax near ExecReader
Message
De
26/01/2008 04:57:25
 
 
À
25/01/2008 14:45:07
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01285618
Message ID:
01285725
Vues:
24
> ... use ExecReader to retrieve records, works fine when there is no input parameters but once I call a stored procedure with input parameters I get following message Line 1: Incorrect syntax near '_Search_Provider_ZipCode'.

Not sure, but I think you're being hit by SQL Server or ADO.NET being "helpful".

Here's the short answer: you shouldn't use ExecReader(..) to call stored procedures. Use ExecSprocReader(..)

The long answer is that your code should actually fail even when there are no parameters.

There is something somewhere than can detect when a stored procedure is being called if you specify just its name. Compare these in Query Analyzer (or SQL Mgmt studio)

(note sp_server_info is a system stored procedure that takes one optional parameter)

sp_server_info



print 'Calling sproc now'
sp_server_info


The first version works, the second doesn't. However change to the correct syntax for calling a stored procedure and it always works:

print 'calling sproc now'
exec sp_server_info


Anyway, switching to ExecSproc / ExecSprocReader etc should fix the problem. Look up "Calling Stored Procedures" in the MM.NET Developer guide.

Hope this helps - Walter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform