www.webdeveloper.com
Results 1 to 2 of 2

Thread: I am programming using .net as front end and SQL server as back end and have the foll

  1. #1
    Join Date
    Jan 2013
    Posts
    1

    I am programming using .net as front end and SQL server as back end and have the foll

    i have the following error in the code. please help me solve it

    Server Error in '/Project' Application.
    --------------------------------------------------------------------------------

    The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

    Source Error:


    Line 35:
    Line 36: DataSet ds = new DataSet();
    Line 37: da.Fill(ds);
    Line 38: GridView1.DataSource = ds;
    Line 39: GridView1.DataBind();

    Source File: c:\Users\Shoaib\Desktop\Project\Admin.aspx.cs Line: 37

    And the code is as given below:

    Collapse | Copy Code
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Configuration;
    using System.Data.SqlClient;
    using System.Data;

    public partial class Admin : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    GridView1.Visible = true;
    }
    string connStr = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
    TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
    Calendar1.Visible = false;
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
    Calendar1.Visible = true;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    SqlConnection con = new SqlConnection(connStr);
    SqlDataAdapter da = new SqlDataAdapter("select UserName, LoginTime, LogoutTime, Upload UploadFile, Download DownloadFile from logindata where ltrim(rtrim(str(month(logintime))))+ '/' + ltrim(rtrim(str(day(logintime)))) + '/' + ltrim(rtrim(str(year(logintime)))) ='" + TextBox1.Text + "'", con);
    //+ "+ Convert.ToDateTime;.Convert.ToDateTime (TextBox1.Text), con);
    //Where Logintime='"+TextBox1.Text+"'", con);

    DataSet ds = new DataSet();
    da.Fill(ds);
    GridView1.DataSource = ds;
    GridView1.DataBind();
    GridView1.Visible = true;
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {

    GridView1.PageIndex = e.NewPageIndex;
    GridView1.DataBind();
    GridView1.Visible = true;

    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    }

  2. #2
    Join Date
    Jan 2013
    Posts
    4
    Just a quick question, are you trying to get the Username, LoginTime, LogoutTime, UploadFile and DownloadFile from logindata where the LoginTime = TextBox1.Text?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles