I'm currently trying to execute a stored procudure with one argument. The database is SQL Server 2005 and I am calling the stored procudure from C# using an OdbcCommand
like this:
OdbcCommand oCmd = new OdbcCommand("{call sp_dominioMaquinas(?)}");
oCmd.Connection = new OdbcConnection(Config.Config.GetConnectionStringSqlConnection());
string psTipoExportarAux = "'" + psTipoExportar + "'";
oCmd.Parameters.Clear();
oCmd.Parameters.Add("@psTipoExportar", OdbcType.VarChar);
oCmd.Parameters["@psTipoExportar"].Value = psTipoExportarAux;
My problem is that my parameter psTipoExportar
is a string with a comma (,) in it (ex: a', 'b
) and so SQL Server recognizes it as two parameters instead of one.
Using a tool to see requests to my database, I can see that my request is being misinterpreted (ex: exec sp_dom '''a'', ''b''') as two arguments when I want it to be processed as one.
If anyone could help out, thank you
I'm following MSDN and I've checked this questions here , here and here.