Error when calling a stored procedure

G

Guest

Hello

I get the SqlException
"A severe error occurred on the current command. The results, if any, should be discarded."
when I call the stored procedure sp_addmergepublication

This is my code
SqlCommand cmd = new SqlCommand()
cmd.Connection = conn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "[sp_addmergepublication]"
cmd.Parameters.Add(@"@publication", "Testing")
cmd.ExecuteNonQuery()

Unless the error, the publication is still created
Calling the same stored procedure in the SQL Query Analyser doesnot give this error

Why do I get this error in my application
Does anyone know a solution

thanks, Marc
 
S

Sahil Malik

Try giving a dbtype to the parameter you are using .. see if that still
gives you this error. Make sure that the DBtype matches whats in the
database.
Also, by any chance are you on framework 1.0? Can you update to 1.1?
Another approach -> Try installing hotfix 815495

- Sahil Malik
Independent Consultant
You can reach me thru my blog at -
http://www.dotnetjunkies.com/weblog/sahilmalik/
 
G

Guest

I think you need to have placeholder in the command text for the parameters
Ex
cmd.CommandText = "[sp_addmergepublication(@publication)]"
O
cmd.CommandText = "[sp_addmergepublication(?)]"
 
G

Guest

Thanks for the replies

Unfortunately these suggestions do not solve the problem

Actually I am calling the sp_addmergepublication in a trigger. This trigger is fired because of an INSERT executed by an ADO.NET SQLCommand

So the problem is not the way how I call the sp_addmergepublication, but that this SP is called as result of the execution of an ADO.NET SQLCommand

I hope someone knows a solution

Marco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top