cmd.CommandText = "SELECT [bookid] FROM [passangers] WHERE (([carrier] = @carrier) AND ([origin] = @origin) AND ([destination] = @destination) AND ([departdate] = @departdate) AND ([arrivaldate] = @arrivaldate))";
bookid is an auto increment field in my sql database table.
Bbaale
Member
64 Points
80 Posts
Sql select statement leaves out the first row.
Feb 08, 2013 04:44 AM|LINK
My sql select statement retrieves all rows apart from the first row. What could be the cause of this? and how to get around it. Thanx.
Rohit Binjol...
Member
84 Points
32 Posts
Re: Sql select statement leaves out the first row.
Feb 08, 2013 04:49 AM|LINK
Can you please provide your statement so i can help..................
wmec
Contributor
6195 Points
3214 Posts
Re: Sql select statement leaves out the first row.
Feb 08, 2013 05:19 AM|LINK
Check the criteria please.
HuaMin Chen
Pbalan.in
Contributor
2142 Points
483 Posts
Re: Sql select statement leaves out the first row.
Feb 08, 2013 06:17 AM|LINK
Please check your sql query, is there any condition based it will retrieve the records.
Bbaale
Member
64 Points
80 Posts
Re: Sql select statement leaves out the first row.
Feb 08, 2013 06:28 AM|LINK
cmd.CommandText = "SELECT [bookid] FROM [passangers] WHERE (([carrier] = @carrier) AND ([origin] = @origin) AND ([destination] = @destination) AND ([departdate] = @departdate) AND ([arrivaldate] = @arrivaldate))";
bookid is an auto increment field in my sql database table.
I also added the parameters respectively.
wmec
Contributor
6195 Points
3214 Posts
Re: Sql select statement leaves out the first row.
Feb 08, 2013 08:43 AM|LINK
Maybe one column of it is having null values. Check this please
HuaMin Chen
raghavendra ...
Participant
1890 Points
435 Posts
Re: Sql select statement leaves out the first row.
Feb 08, 2013 11:07 AM|LINK
If any column have NULL value use ISNULL sql function to get that record
limno
All-Star
117314 Points
7997 Posts
Moderator
MVP
Re: Sql select statement leaves out the first row.
Feb 08, 2013 03:05 PM|LINK
Try to run your query in SSMS first. Check your code to see whether you have read past the first row alread in your code.
Format your SQL query with instant sql formatter:
http://www.dpriver.com/pp/sqlformat.htm
stockcer
Member
498 Points
128 Posts
Re: Sql select statement leaves out the first row.
Feb 08, 2013 03:35 PM|LINK
A couple of ideas....
1. When you run this directly against sql (without using visual studio) do you get the same returned data as when you run it within visual studio.
2. Look at SQL profiler and see what is actually being run against the server.
ASP.NET Arvixe Liaison
James River Webs, Inc.