0

How can i send the default keyword as a SAParameter to a stored procedure?

I have a stored procedure called procedureEx that takes 3 parameters and the last one has a default value

I can call it with from sql with call procedureEx('test', 1, default)

But how can i do this from .net with parameterized query. In the real code i can get the parameter or not and i want the database to control the default value

command.CommandText = "call procedureEx(?,?,?)";
command.Parameters.Add(new SAParameter("", "test");
command.Parameters.Add(new SAParameter("", 1);
command.Parameters.Add(new SAParameter("", default); // <- how do i do this?
klundby
  • 301
  • 1
  • 3
  • 17

1 Answers1

1

This code may help you on the way:

command.CommandText = "call procedureEx(?,?,?)";
command.Parameters.Add(new SAParameter("", "test");
command.Parameters.Add(new SAParameter("", 1);
command.Parameters.Add(new SAParameter("", SADefault.Value); 

I tested the code using some dummy data, but it gave me a "Not enough values for host variables" exception, but the code may lead you to the correct solution...

estromsnes
  • 146
  • 9