Click here to Skip to main content
15,908,776 members
Home / Discussions / C#
   

C#

 
QuestionIDbParameter return value string only gives first character Pin
jVersteegen24-Sep-08 23:35
jVersteegen24-Sep-08 23:35 
hello
I am trying to get the return parameter from database stored procedure (very simple basic test):

create procedure TQMSpGetConcattenatedString @string1 varchar(50),@string2 varchar(50),@string3 varchar(50) output
as
set nocount on
select @string3 = @string1 + @string2

works fine when execute in query analyser. Then try to execute from C# code as follows:

private static string test2()
{
IDbCommand cmd = Program.db.GetCommand ();
cmd.Connection = Program.db.Connection;
cmd.CommandText = "TQMSpGetConcattenatedString";
cmd.CommandType = CommandType.StoredProcedure ;

IDataParameter p1 = Program.db.getDataParameter ();
p1.ParameterName = "@string1";
p1.Direction = ParameterDirection.Input ;
p1.DbType = DbType.String ;
p1.Value = "Monkey";
cmd.Parameters.Add (p1);

IDataParameter p2 = Program.db.getDataParameter ();
p2.ParameterName = "@string2";
p2.Direction = ParameterDirection.Input ;
p2.DbType = DbType.String ;
p2.Value = "Tail";
cmd.Parameters.Add (p2);

IDataParameter p3 = Program.db.getDataParameter ();
p3.ParameterName = "@string3";
p3.Direction = ParameterDirection.Output;
p3.DbType = DbType.String ;
p3.Value = "-";
cmd.Parameters.Add (p3);

cmd.ExecuteNonQuery ();
return p3.Value.ToString();
}

the return string only has 1 character in it. When i use SqlParameter it works good.
Does anybody have a suggestion for me?
AnswerRe: IDbParameter return value string only gives first character Pin
Pete O'Hanlon25-Sep-08 0:09
mvePete O'Hanlon25-Sep-08 0:09 
GeneralRe: IDbParameter return value string only gives first character Pin
jVersteegen25-Sep-08 0:16
jVersteegen25-Sep-08 0:16 
GeneralRe: IDbParameter return value string only gives first character Pin
Ashfield25-Sep-08 0:24
Ashfield25-Sep-08 0:24 
GeneralRe: IDbParameter return value string only gives first character Pin
jVersteegen25-Sep-08 0:37
jVersteegen25-Sep-08 0:37 
GeneralRe: IDbParameter return value string only gives first character Pin
Pete O'Hanlon25-Sep-08 1:08
mvePete O'Hanlon25-Sep-08 1:08 
GeneralRe: IDbParameter return value string only gives first character Pin
jVersteegen25-Sep-08 1:31
jVersteegen25-Sep-08 1:31 
GeneralRe: IDbParameter return value string only gives first character Pin
Pete O'Hanlon25-Sep-08 1:59
mvePete O'Hanlon25-Sep-08 1:59 
GeneralRe: IDbParameter return value string only gives first character Pin
jVersteegen25-Sep-08 2:29
jVersteegen25-Sep-08 2:29 
GeneralRe: IDbParameter return value string only gives first character Pin
jVersteegen25-Sep-08 2:39
jVersteegen25-Sep-08 2:39 
QuestionDateTimePicker and BindingSource Problem Pin
Ahmad Safwat24-Sep-08 23:31
Ahmad Safwat24-Sep-08 23:31 
AnswerRe: DateTimePicker and BindingSource Problem Pin
Acid_Inex25-Sep-10 18:25
Acid_Inex25-Sep-10 18:25 
AnswerRe: DateTimePicker and BindingSource Problem Pin
PeSVe24-Aug-12 3:59
PeSVe24-Aug-12 3:59 
Questiondelegate Pin
Mogaambo24-Sep-08 23:26
Mogaambo24-Sep-08 23:26 
AnswerRe: delegate Pin
leppie24-Sep-08 23:28
leppie24-Sep-08 23:28 
GeneralRe: delegate Pin
Mogaambo25-Sep-08 0:08
Mogaambo25-Sep-08 0:08 
GeneralRe: delegate Pin
leppie25-Sep-08 0:16
leppie25-Sep-08 0:16 
JokeRe: delegate Pin
DaveyM6925-Sep-08 0:18
professionalDaveyM6925-Sep-08 0:18 
AnswerRe: delegate Pin
Mark Churchill25-Sep-08 0:54
Mark Churchill25-Sep-08 0:54 
QuestionRegularExpressionValidator Pin
AtulRane24-Sep-08 23:16
AtulRane24-Sep-08 23:16 
AnswerRe: RegularExpressionValidator Pin
leppie24-Sep-08 23:27
leppie24-Sep-08 23:27 
Questionreport of proc Pin
NiloofarNoroozi24-Sep-08 22:54
NiloofarNoroozi24-Sep-08 22:54 
QuestionHTML to RTF Pin
omlac24-Sep-08 22:14
omlac24-Sep-08 22:14 
QuestionProblem with serialisation in C# Pin
Sudarsan Srinivasan24-Sep-08 22:10
Sudarsan Srinivasan24-Sep-08 22:10 
AnswerRe: Problem with serialisation in C# Pin
Giorgi Dalakishvili24-Sep-08 22:33
mentorGiorgi Dalakishvili24-Sep-08 22:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.