本文介绍了SqlDataReader不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
在下面的代码中,控制永远不会进入while循环内部:
Hi to all,
In below code, control never goes inside while loop:
string temp = "";
lbl.Text = "";
Connection_c c = new Connection_c();
SqlDataReader reader;
SqlCommand command = new SqlCommand("SelectTask", c.conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@date", SqlDbType.NChar).Value = Date.Text;
command.Parameters.Add("@username", SqlDbType.NVarChar).Value=
Username.Text;
c.conn.Open();
reader = command.ExecuteReader();
while (reader.Read())
{
temp = reader["Title"].ToString();
lbl.Text += temp +"<br/>";
}
reader.Close();
c.conn.Close();
StoredProcedure:
StoredProcedure:
@date nchar(10),@username nvarchar(20)
AS
/* SET NOCOUNT ON */
Select Title FROM Task_table WHERE ((startDate>@date OR startDate=@date)AND
(endDate<@date OR endDate=@date)AND (Status <>'completed' AND Status<>'interrupt') AND (Username=@username) )
RETURN
请帮助我.
please help me.
推荐答案
这篇关于SqlDataReader不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!