开发者

sql data reader showing one record less than sql query output

i have made a simple stored开发者_高级运维 procedure to select all records where name will be like '%search text%'. the the stored procedure is returning correct results. But when i tried to show these result set into gridview using sqldatareader, it populate one record less. Help Pls.


SqlConnection conn = new SqlConnection(connectionString);

SqlCommand command = new SqlCommand("select * from yourtable where yourcol like @parm" );
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@parm", searchText);

conn.Open();
command.Connection = conn;
SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
GridView1.DataSource = reader;
GridView1.DataBind();

if you're looping through the SqlDataReader, it's zero based.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜