.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

select record based on / match selected date

Posted By:      Posted Date: October 01, 2010    Points: 0   Category :ASP.Net
with the sql statement below, i try to select the records based on the selected date, it return no rows from adapter filled datatable. 
however, when i run the query in sql query in sql server studio management, it returns records. 
date format = 09/28/2010

string[] splitDT = txtSelectedDate.Text.Split('/');

            string strRearrangeDT = splitDT[0] + "/" + splitDT[1] + "/" + splitDT[2];

using (SqlConnection sqlconn = new SqlConnection(connstring))
                DataTable dt = new DataTable();
                string strSQL = "SELECT userclaim_details3.id, userclaim_details3.userclaimid, userclaim_details3.userid, userclaim_details3.childcategorytableid, userclaim_details3.statusid, " +
                         "userclaim_details3.amount AS amountname, userclaim_details3.remark AS remarkname, userclaim_details3.datecreated AS datecreatedname, " +
                         "userclaim_details3.datemodified, approvaltable.id AS Expr1, approvaltable.typename AS statusname, usertable2.id AS Expr2, usertable2.name AS uname, " +
                         "childcategorytable.id AS Expr3, childcategorytable.categor

View Complete Post

More Related Resource Links

Select columns based on date in row kinda like a cross tabe


I have a querry that will add data to a temp table for a period given the begin date and end date, for each month that there is data i need to have a column, which i did with :



(case when Month([Date])=1 then

Need to select records based on todays date


I need to select records in my database based on todays date. I have a date field that saves a future scheduled ship date for orders and need to use a select statement that would use todays date as a parameter. I am able to do this by manualy entering the date in the select statement but when I use todays date with inline code in the select statement it does not work. Please look at the code segment below:

Dim strTodaysDate As String
strTodaysDate = "'" + Date.Now.AddDays(9).ToString("MM/dd/yyyy") + "'"

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:DAVINCIORDERTRACKINGConnectionString %>"
        SelectCommand="SELECT * FROM [OrderTracker] WHERE (CONVERT(char(10), ScheduledShipDate, 101) <> '<% =strTodaysDate %>')">


The segment above returns all records. And if I just enter the date manually in the select statement like below it returns the correct records:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:DAVINCIORDERTRACKINGConnectionString %>"

The XML Files: XSLT Keys, Select vs. Match, Conflict Resolution, and More


This month Aaron Skonnard covers how keys work in XSLT, XSLT match and select attributes, SelectNodes order, finding