I guess this is bad practice but i have an SQL 2000 SP that uses a
single varchar(100) parameter for input and output. I would like to
use an SQLcommand object to call it but this doesn't seem to work,
here's my code:
SqlParameter ParamSessionID = new SqlParameter("@SessionID",
SqlDbType.VarChar, 100);
ParamSessionID.Direction = ParameterDirection.InputOutput;
Comm1.Parameters.Add(ParamSessionID);
Comm1.Parameters["@SessionID"].Value =
m_currentPage.Session.SessionID;
Comm1.CommandType = CommandType.StoredProcedure;
Conn.Open();
Comm1.ExecuteScalar();
The error i get is 'System.Data.SqlClient.SqlException: String or
binary data would be truncated.'
Using the debugger i can see the value of the parameteris as a 25
charected string.
SQL profiler shows the following command being issued:
declare @P1 varchar(100)
set @P1=NULL
exec sp_CevasSessionCreate @SessionID = @P1 output
select @P1
This seems to suggest that SQLClient doesn't implement InputOutput as
expected, i could get the data by setting the commandtype to text and
using ExecuteScalar but it would be nice to do this via the command
object.
Any ideas?
Micky