M
m.moebius
I have a strange behaviour. Perhaps someone can look through if there
is anything obvious wrong.
The field ProjAdmin is a tinyint
SqlConnection con = CreateConnection(); con.Open();
string sql =" UPDATE tblEmployee " +
" SET ProjAdmin = @param WHERE (EmployerID = 1002)";
SqlCommand cmd = new SqlCommand(sql,con);
SqlParameter para = cmd.Parameters.Add("@param",0);
//uncomment to get it working
//para.Value = 0;
cmd.ExecuteNonQuery();
The above throws the following error:
Prepared statement '(@param bigint) UPDATE tblEmployee SET ProjAdmin =
@param WHERE' expects parameter @param, which was not supplied.
The funny thing is, after uncommenting par.Value = 0; all is working
fine.
Also exchanging 0 with any other number works without the
para.Value = 0 statement.
Only when updating with 0 the error is thrown.
So I would consider this a bug. I would be interested to hear what is
going on there. A short look with Reflector gave me the impression that
Add("param",value) is equal to para.name = "param"; para.Value = value;
SELECT @@VERSION
Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002
14:22:05 Copyright (c) 1988-2003 Microsoft Corporation Enterprise
Edition on Windows NT 5.2 (Build 3790: )
..net 1.1.4322
is anything obvious wrong.
The field ProjAdmin is a tinyint
SqlConnection con = CreateConnection(); con.Open();
string sql =" UPDATE tblEmployee " +
" SET ProjAdmin = @param WHERE (EmployerID = 1002)";
SqlCommand cmd = new SqlCommand(sql,con);
SqlParameter para = cmd.Parameters.Add("@param",0);
//uncomment to get it working
//para.Value = 0;
cmd.ExecuteNonQuery();
The above throws the following error:
Prepared statement '(@param bigint) UPDATE tblEmployee SET ProjAdmin =
@param WHERE' expects parameter @param, which was not supplied.
The funny thing is, after uncommenting par.Value = 0; all is working
fine.
Also exchanging 0 with any other number works without the
para.Value = 0 statement.
Only when updating with 0 the error is thrown.
So I would consider this a bug. I would be interested to hear what is
going on there. A short look with Reflector gave me the impression that
Add("param",value) is equal to para.name = "param"; para.Value = value;
SELECT @@VERSION
Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002
14:22:05 Copyright (c) 1988-2003 Microsoft Corporation Enterprise
Edition on Windows NT 5.2 (Build 3790: )
..net 1.1.4322