Tuesday, March 27, 2012

find the table in different Store procedure

how we know, selected table is used in how much store procedure.

 SELECT DISTINCT OBJECT_NAME(id) FROM syscomments WHERE [text] LIKE '%aaaa%'

Wednesday, January 25, 2012

Find files in folder or directory


use to find out the files in folder or directory and compare it with database and not comparable are inserted into temp table and at last will show on gird view.

       DataTable dt = new DataTable();
        dt.Columns.Add("ImageName");
        dt.Columns.Add("ImagePath");
       
        DataSet ds = Utils.GetImageFolderNames();
        DataSet dsImage = Utils.GetAllImages();
        DataTable dtImages=dsImage.Tables[0];
        DataView dv = new DataView(dsImage.Tables[0]);

        if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count>0)
        {
            foreach (DataRow row in ds.Tables[0].Rows)
            {
               string folderPath=Server.MapPath(ResolveUrl("~/images/" + row["folderName"]+"/"));
               if (Directory.Exists(folderPath))
               {
                   DirectoryInfo mydir = new DirectoryInfo(folderPath);
                   if (mydir.Exists)
                   {
                       FileInfo[] fil = mydir.GetFiles();
                       foreach (FileInfo fl in fil)
                       {
            dv.RowFilter = "FileName='" + fl.Name + "' or " + "ThumbNailImageName='" + fl.Name+"'";
                           if (dv.Count <= 0)
                           {
                               DataRow dr = dt.NewRow();
                               dr["ImageName"] = fl.Name;
                               dr["ImagePath"] = fl.FullName;
                               dt.Rows.Add(dr);
                               dt.AcceptChanges();
                           }
                       }
                   }
               }
            }
        }
       
        gvData.DataSource = dt;
        gvData.DataBind();