i want to compare the name and date and case attended with database. the problem i was facing in date field. beacuse in database i stored both date and time n single field. now i want to compare just date only and ignore time option from database field. if the comparison is equal means not to insert the data in my database and saying already existing.
dt4 = load.getchkRegistration(Pname, AppDate);
if (dt4.Rows.Count == 0)
{
if (btnrdex.BackColor == Color.DodgerBlue)
{
load.InsertRegistrationEx(RegistrationID, PatientIDEx, P_Name, Gender, MaStatus, DOB, Age, Address, City, Pincode, Mobile, AltMobile, Email, RefDoc, AppDate, Doneon, User);
}
else
{
mpealert.Show();
}
public DataTable getchkRegistration(string P_Name, string AppDated)
{
SqlDataAdapter DBAdap = default(SqlDataAdapter);
SqlConnection conn = new SqlConnection(constr);
conn.Open();
SqlCommand dCmd = new SqlCommand("select * from Registration where P_Name=@P_Name and AppDated=@AppDated and CaseAtten='Not Attended'", conn);
dCmd.CommandType = CommandType.Text;
//dCmd.Parameters.AddWithValue("@Patient_ID", Patient_ID);
dCmd.Parameters.AddWithValue("@P_Name", P_Name);
dCmd.Parameters.AddWithValue("@AppDated", AppDated);
DataTable dTable = new DataTable();
try
{
DBAdap = new SqlDataAdapter(dCmd);
DBAdap.Fill(dTable);
return dTable;
DBAdap.Fill(dTable);
return dTable;
}
catch (Exception ex)
{
throw;
}
finally
{
dTable.Dispose();
DBAdap.Dispose();
conn.Close();
dCmd.Dispose();
conn.Dispose();
}
}