tors
Дата: 20.05.2005 16:14:10
Есть такая ХП:
create procedure GetMessagesCount
@Count int OUTPUT,
@User varchar(100)=NULL
AS
IF isNull(@User,'')=''
select @Count=COUNT(*) from messages;
ELSE
select @Count=COUNT(*) from messages
where UserName=@User;
и есть такой код:
System.Data.SqlClient.SqlConnection Connection=new SqlConnection();
Connection.ConnectionString=ConnectionString;
System.Data.SqlClient.SqlCommand Command=new SqlCommand();
Command.Connection=Connection;
Command.CommandType=CommandType.StoredProcedure;
Command.CommandText="GetMessagesCount";
SqlParameter Param=new SqlParameter("Count",SqlDbType.Int);
Param.Direction=ParameterDirection.Output;
Command.Parameters.Add(Param);
Connection.Open();
int Count=(int)Command.Parameters["Count"].Value;
Connection.Close();
В стороке int Count=(int)Command.Parameters["Count"].Value; - ошибка(те Value==null)
В чем траблы?
C ув. Tors