Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7025131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:56:02+00:00 2026-05-27T23:56:02+00:00

Hey I would like to display certain data with my stored procedure for the

  • 0

Hey I would like to display certain data with my stored procedure for the last 30 days. here is what I have done (aspx.cs file):

 protected void Page_Load(object sender, EventArgs e)     
        {
          DateTime toDate, fromDate;
          toDate = DateTime.Now;

          fromDate = toDate.Subtract(new TimeSpan(31, 0, 0, 0));

          SqlDataSource1.SelectParameters.Add("fromDate", DbType.DateTime, fromDate.ToString());
          SqlDataSource1.SelectParameters.Add("toDate", DbType.DateTime, toDate.ToString());                    

    }

here is my aspx file

 <form id="form1" runat="server">
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" Width="232px" DataKeyNames="CustomerId" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="CreationDate" HeaderText="CreationDate" SortExpression="CreationDate" />
            </Columns>
        </asp:GridView>
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SSEnewConnectionString %>"
            SelectCommand="procCustomer_SelectbyCreationDate" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter DbType="DateTime" Name="fromDate" />
                <asp:Parameter DbType="DateTime" Name="toDate" />
            </SelectParameters>
        </asp:SqlDataSource>
        </form>

when I test this my screen comes up blank (other than the masterpage elements) and no errors. any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:56:03+00:00Added an answer on May 27, 2026 at 11:56 pm

    EDIT: Even though an earlier version of this answer was accepted, it looks like I had misunderstood the parameter type used. The web controls ParameterCollection looks somewhat awful.

    I would suggest converting date values to a SQL format (much as that pains me, frankly – string conversions should be avoided as far as possible). For example:

    SqlDataSource1.SelectParameters.Add("fromDate", DbType.DateTime,
        fromDate.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture));
    SqlDataSource1.SelectParameters.Add("toDate", DbType.DateTime,
        toDate.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture));
    

    (Change to yyyy-MM-dd for date-only types.)

    I haven’t used SqlDataSource myself, but it also looks like you’re introducing the parameters twice – once in the markup, and once in the code. Given that you don’t have the values in the markup (including in bindings), you may want to remove them from there – but I could be wrong on that front.

    If your query isn’t doing what you expect, you should check your database logs (or whatever tool is appropriate) to check what actual query is executing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey. I have an XML file and would like to use PHP to display
Hey everyone. I would like to create a joomla menu but have it display
Hey. I would like to upload a file and then parse it. Because parsing
Hey guys, I have developed a small site that i would like to embed
Hey guys, I have an application that I want to display some data from
Hey i would like do have your input on this I use this to
Hey all. Okay here is the situation. I would like to be able to
Hey all. So I have a collection of csv files which I would like
Hey guys. I would like to set up the alias in my enviromental file
Hey all i have created dynamic buttons at runtime and i would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.