J
John
Hi
I have a winform app with sql server 2008 backend. I am using strongly typed
dataset with dataadapter to access data from an sql server table. I am using
below four SQL with the dataadapter to access First, Next, Prev and Last
records respectively;
First
SELECT TOP 1 <field list>
FROM Clients
WHERE (Status = @Status)
ORDER BY CompanyID
Next
SELECT TOP 1 <field list>
FROM Clients
WHERE (CompanyID > ?) AND (Status = @Status)
ORDER BY CompanyID
Prev
SELECT TOP 1 <field list>
FROM Clients
WHERE (CompanyID < ?) AND (Status = @Status)
ORDER BY CompanyID DESC
Last
SELECT TOP 1 <field list>
FROM Clients
WHERE (Status = @Status)
ORDER BY CompanyID DESC
My questions are;
1. What modifications do I need for when @Status is null?
2. What modifications do I need for when ORDER BY is a field other than
CompanyID?
3. Am I better off implementing these as stored procedures, in CLR etc.?
Many Thanks
Regards
I have a winform app with sql server 2008 backend. I am using strongly typed
dataset with dataadapter to access data from an sql server table. I am using
below four SQL with the dataadapter to access First, Next, Prev and Last
records respectively;
First
SELECT TOP 1 <field list>
FROM Clients
WHERE (Status = @Status)
ORDER BY CompanyID
Next
SELECT TOP 1 <field list>
FROM Clients
WHERE (CompanyID > ?) AND (Status = @Status)
ORDER BY CompanyID
Prev
SELECT TOP 1 <field list>
FROM Clients
WHERE (CompanyID < ?) AND (Status = @Status)
ORDER BY CompanyID DESC
Last
SELECT TOP 1 <field list>
FROM Clients
WHERE (Status = @Status)
ORDER BY CompanyID DESC
My questions are;
1. What modifications do I need for when @Status is null?
2. What modifications do I need for when ORDER BY is a field other than
CompanyID?
3. Am I better off implementing these as stored procedures, in CLR etc.?
Many Thanks
Regards