Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Getting after convertin date time,Conversion failed when converting date and/or time from character string.

$
0
0

i am getting after convertin date time

  private void LoadData()
    {
        con.Open();
        string s = "SELECT user_name FROM login" + " WHERE user_name='" + Label1.Text + "'";
        SqlCommand cmd = new SqlCommand(s, con);
        SqlDataReader Dr = cmd.ExecuteReader();
        if (Dr.Read())
        {
            con.Close();
            DateTime datetime = Convert.ToDateTime(Date.Text);
            string query = @"SELECT id,problem,ip,date_time,Rec_Status FROM  Tech_data where Call_assign='" + Label1.Text + "'  and date_time='" + datetime  + "'";

            SqlDataAdapter da = new SqlDataAdapter(query, con);
            DataTable table = new DataTable();
            da.Fill(table);  <<<---- error

            GridView1.DataSource = table;
            GridView1.DataBind();
        }

    }




Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>