com = new SqlCommand("SELECT MAX(createddate) FROM Payout_Master WHERE sponcorid='" + code + "'", con); DateTime date = (DateTime)com.ExecuteScalar();//HERE M GETTING ERROR OF CASTING if(date!=DateTime.Now.Date) { }
using( SqlConnection cn =new SqlConnection(ConfigurationManager.ConnectionStrings["Conection Name here"].ConnectionString)) { SqlCommand com=new SqlCommand(); com = new SqlCommand("SELECT MAX(createddate) FROM Payout_Master WHERE sponcorid='" + code + "'", con); con.Open(); var OrderDate = (String)com.ExecuteScalar(); if(!string.IsNullOrEmpty(OrderDate)) { DateTime oDate = Convert.ToDateTime(OrderDate); // rest of the code. } }
WHERE sponcorid='" + code + "'
string str = Convert.ToString(com.ExecuteScalar()); DateTime date = DateTime.Parse(str);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)