Click here to Skip to main content
15,908,254 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm getting error in parameter direction output in sqlce query for paging.

What I have tried:

SQL
SELECT ROW_NUMBER() OVER (ORDER BY [invoiceId] desc) AS RowNumber,invoiceId,invoice.customerName,invoice.custId,customerPhone,customerAddress,packageName,packageId,amountIncTax,fromDate,toDate,needTrainer,assignedTrainerName,assignedTrainerId,trainerFromDate,trainerToDate,trainerFeesPerMonth,trainerTotPaid,finalFeeAmountIncTax,discountPerc,discountAmount,finalFeeIncTaxAfterDisc,taxPerc,taxAmount,paidOn,paidAmnt,invoicePrinted into #Results from invoice inner join master_customer on master_customer.custId=invoice.custId WHERE lower('Inv'+(cast(invoiceId as varchar(max)))+' '+invoice.customerName+' '+REPLACE(CONVERT(VARCHAR,fromDate, 106), ' ', '-')+' '+REPLACE(CONVERT(VARCHAR,toDate, 106), ' ', '-')+' ') LIKE +'%' + @SearchTerm + '%';
 SELECT @RecordCount = COUNT(*) FROM #Results;
SELECT * FROM #Results WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1; DROP TABLE #Results;



and then my parameters are

C#
cmd.Parameters.AddWithValue("@PageSize", pageSize);
                    cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
                    cmd.Parameters.AddWithValue("@SearchTerm", searchQuery.ToLower().Trim());
                    cmd.Parameters.Add("@RecordCount", SqlDbType.Int);
                    cmd.Parameters["@RecordCount"].Direction = ParameterDirection.Output;


I'm getting error in parameter direction output. but for paging purpose i need it because all example in internet using this type of query for paging.
Posted
Updated 16-May-16 19:06pm

1 solution

Hello ,
Output Parameter is not supported in SqlCe . Instead of that , you may use ExecuteScalar method .
int recordcount= (int)cmd.ExecuteScalar();

Thanks
 
Share this answer
 
v2
Comments
souvikcode 17-May-16 3:38am    
can you please give example where to write that? I have posted full query so that users can give me answer with where to change. With my query above where should I write cmd.ExecuteScalar()?
Animesh Datta 17-May-16 7:31am    
You simple call it at bottom after adding parameters
cmd.Parameters.AddWithValue("@PageSize", pageSize);
cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
cmd.Parameters.AddWithValue("@SearchTerm", searchQuery.ToLower().Trim());
//call here
int recordcount= (int)cmd.ExecuteScalar();
souvikcode 17-May-16 7:36am    
okk,got it.thanks.
Animesh Datta 17-May-16 8:20am    
if your problem solved then accept the answer so that it will not appear in unanswered list

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900