May 20, 2004 at 11:02 am
Im trying to pass a string using C# to a stored procedure, yet it only registers one letter of my string, i can pass ints successfully with out issue, does anyone know why???
string p22 ="hello" ;
SqlCommand ocmd = new SqlCommand("EXEC transact '"+p22+"'", sqlConn);
ocmd.CommandType = CommandType.Text;
SqlDataReader oreader = ocmd.ExecuteReader();
oreader.Close();
May 20, 2004 at 12:44 pm
Can you post the text of the stored proc? Or at least the signature?
May 21, 2004 at 7:14 am
Hi Lane,
Please check the length of the datatype you have used in ur stored proc(sp). I assume u have used varchar as ur datatype. If u have not given any length than it will take the first character of the string that u have passed as a parameter to u r sp.
by the way please post ur sp if u could.
bye
May 21, 2004 at 2:20 pm
Build the string first and then print to the console to verify that they command is correct (or you can use profiler).
string p22 ="hello" ;
string tSQL = "EXEC transact '"+p22+"'";
--Print to console or whatever to check string
SqlCommand ocmd = new SqlCommand(tSQL , sqlConn);
ocmd.CommandType = CommandType.Text;
SqlDataReader oreader = ocmd.ExecuteReader();
oreader.Close();
take the output and run directly in Query Analyser and verify that your getting the expected results. If not, then I have no idea what's wrong.
Signature is NULL
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply