Click here to Skip to main content
15,908,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
select reg.nregisterid as RegNo,reg.semailid as Email,reg.ntradingoptionname as TradingOption,toperiod.ntradingoptionperiod as Period,reg.totalamount as Total,suserstatus as Status 
from tbregistermember as reg 
JOIN tbuserstatus as s on reg.nuserstatusid=s.nuserstatusid 
JOIN tbtradingoptionperiod as toperiod on reg.ntradingoptionperiodid=toperiod.ntradingoptionperiodid 
where dregistrationdate between " + frmdate.Text + "
and " + todate.Text + " 
and reg.nuserstatusid = " + Ddlstatus.SelectedValue + "
Posted
Updated 22-May-12 19:42pm
v2
Comments
Wendelius 23-May-12 1:42am    
It would help a lot if you post the error message you get

One possible error is coming from your input. If the text boxes have for example illegal characters etc you will see an error message.

Concatenating literal values to an SQL statement is considered a bad habit. The reason is that you're vulnerable to SQL injections, data type mismatches and so on.

Instead of adding the values directly to your SQL statement, use SqlParameter[^]
 
Share this answer
 
Comments
VJ Reddy 23-May-12 1:45am    
Good suggestion. 5!
Wendelius 23-May-12 2:08am    
Thanks :)
put alias name before "dregistrationdate" and " +"'"+ frmdate.Text +"'"+" and " +"'"+ todate.Text +"'"+ "
 
Share this answer
 
Missing alias name of dregistrationdate coloumn
 
Share this answer
 
you write your where condition of date between:-
where dregistrationdate between " + frmdate.Text + "
and " + todate.Text + "

instead of write like this :-

SQL
where dregistrationdate between '" + frmdate.Text + "' and
'" + todate.Text + "'


use '"+ +"' for date not use "+ +".
it will work.
 
Share this answer
 
replace your query with this
select reg.nregisterid as RegNo,reg.semailid as Email,reg.ntradingoptionname as TradingOption,toperiod.ntradingoptionperiod as Period,reg.totalamount as Total,suserstatus as Status from tbregistermember as reg JOIN tbuserstatus as s on reg.nuserstatusid=s.nuserstatusid JOIN tbtradingoptionperiod as toperiod on reg.ntradingoptionperiodid=toperiod.ntradingoptionperiodid where dregistrationdate between '" + frmdate.Text + "' and '" + todate.Text + "' and reg.nuserstatusid = " + Ddlstatus.SelectedValue



its a good practise to use parameterized queries so that you will be out of sqlinjection attacks.
 
Share this answer
 

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