Below is my query I want to fetch last entry of visitno
,of particular pid
,this query works fine but selects all rows of pid ,visistNo is of Number Datatype
public int GetPatientID_visitNo(int pid)
{
int data = 0;
try
{
string sql = "Select VisitNo From Patient_Visit_Details where Patient_ID = " + pid;
cmd = new OleDbCommand(sql, acccon);
rs = cmd.ExecuteReader();
if (rs.HasRows)
{
data = Convert.ToInt32(rs[0]);
}
}
catch (Exception err)
{
}
return data;
}
when I try below Query it gives me error no data exist
since my table is new and it dosn't contain any row ,how I can Do this
string sql = "Select MAX(VisitNo) From Patient_Visit_Details where Patient_ID = " + pid;