I have this query:
CREATE PROCEDURE [dbo].[spGetUserAvatar]
( @userid int)
AS
BEGIN
select avatar
from t_user
where (userID = @userid) AND (avatar<>null)
end
and this C# code to execute this query:
string ConnectionString = SafaConnectionString.ConnectionString;
SqlConnection Connection = new SqlConnection(ConnectionString);
SqlCommand cmd = new SqlCommand("spGetUserAvatar", Connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@userid", userid);
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter();
try
{
cmd.Connection = Connection;
Connection.Open();
sda.SelectCommand = cmd;
sda.Fill(dt);
if (dt.Rows.Count > 0)
return dt;
else
return null;
}
It worked fine,but now returns dt.Rows.Count == 0
.In the event that,
t_users.avatar Is not empty.
Have I got the query wrong?