Below is my code which is used to check file already exists or not
var flag1 = CheckFileExist(Session["subjectname"].ToString());
if (!flag1)
return;
private bool CheckFileExist(string SubjName)
{
var flag1 = false;
string qry = string.Empty;
if (Type == "Add")
{
if (Stype == "3")
{
qry ="select ID,Subjectnames,stuName from students where subjectnames='" + SubjName + "'";
}
else
{
qry = "select ID,Subjectnames,stuName from students where subjectnames='" + SubjName + "'";
}
}
else
{
if (Stype == "3")
{
qry = "select ID,Subjectnames,stuName from students where subjectnames='" + SubjName + "'";
}
else
{
qry = "select ID,Subjectnames,stuName from students where subjectnames='" + SubjName + "'";
}
}
SqlCommand cmd = new SqlCommand(qry, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
if (HasFile == false)
{
lblerrmsg.Visible = true;
lblerrmsg.Text = "File Already Exist ...!";
return false;
}
else
{
lblerrmsg.Visible = true;
lblfname.Text = "";
lbldocname.Text = "";
pnl1.Visible = true;
btnupdate.Enabled = false;
lblerrmsg.Visible = true;
btnadd.Enabled = true;
string Subjects = "select ID, Subject from Subjects where Module = '" + null + "'";
BindDropDownList(ddlsubjname, Subjects, "Subject", "ID", "--Select--");
lblerrmsg.Text = "File Already Exist ...!";
if (IsPostBack)
{
BindGrid();
}
Clear();
return false;
}
}
flag1 = true;
return flag1;
}
the problem is i will be uploading mutiple sheets for a subject it should check whether that sheet is alread there for that subject or not this code is working fine when i take single documnet in file uploader if i am taking mutiple file it is not checking for all the multiple files instead it is getting returned after checking the first file only.how can i resolve this