private static Guid CreatePath(int siteId, String path) { Guid newPathID = Guid.NewGuid(); Guid siteGuid = DBSiteSettings.GetSiteGuidFromID(siteId); StringBuilder sqlCommand = new StringBuilder(); sqlCommand.Append("INSERT INTO mp_SitePaths (PathID, SiteID, SiteGuid, Path, LoweredPath)"); sqlCommand.Append("VALUES ("); sqlCommand.Append(" @PathID , "); sqlCommand.Append(" @SiteID , "); sqlCommand.Append(" @SiteGuid , "); sqlCommand.Append(" @Path , "); sqlCommand.Append(" @LoweredPath "); sqlCommand.Append(");"); SqlCeParameter[] arParams = new SqlCeParameter[5]; arParams[0] = new SqlCeParameter("@PathID", SqlDbType.UniqueIdentifier); arParams[0].Direction = ParameterDirection.Input; arParams[0].Value = newPathID; arParams[1] = new SqlCeParameter("@SiteID", SqlDbType.Int); arParams[1].Direction = ParameterDirection.Input; arParams[1].Value = siteId; arParams[2] = new SqlCeParameter("@Path", SqlDbType.NVarChar, 255); arParams[2].Direction = ParameterDirection.Input; arParams[2].Value = path; arParams[3] = new SqlCeParameter("@LoweredPath", SqlDbType.NVarChar, 255); arParams[3].Direction = ParameterDirection.Input; arParams[3].Value = path.ToLower(); arParams[4] = new SqlCeParameter("@SiteGuid", SqlDbType.UniqueIdentifier); arParams[4].Direction = ParameterDirection.Input; arParams[4].Value = siteGuid; int rowsAffected = Convert.ToInt32(SqlHelper.ExecuteNonQuery( GetConnectionString(), CommandType.Text, sqlCommand.ToString(), arParams).ToString()); return(newPathID); }
public static Guid CreatePath(int siteId, String path) { Guid newPathID = Guid.NewGuid(); Guid siteGuid = DBSiteSettings.GetSiteGuidFromID(siteId); StringBuilder sqlCommand = new StringBuilder(); sqlCommand.Append("INSERT INTO mp_SitePaths (PathID, SiteID, SiteGuid, Path, LoweredPath)"); sqlCommand.Append("VALUES ("); sqlCommand.Append(" ?PathID , "); sqlCommand.Append(" ?SiteID , "); sqlCommand.Append(" ?SiteGuid , "); sqlCommand.Append(" ?Path , "); sqlCommand.Append(" ?LoweredPath "); sqlCommand.Append(");"); MySqlParameter[] arParams = new MySqlParameter[5]; arParams[0] = new MySqlParameter("?PathID", MySqlDbType.VarChar, 36); arParams[0].Direction = ParameterDirection.Input; arParams[0].Value = newPathID.ToString(); arParams[1] = new MySqlParameter("?SiteID", MySqlDbType.Int32); arParams[1].Direction = ParameterDirection.Input; arParams[1].Value = siteId; arParams[2] = new MySqlParameter("?Path", MySqlDbType.VarChar, 255); arParams[2].Direction = ParameterDirection.Input; arParams[2].Value = path; arParams[3] = new MySqlParameter("?LoweredPath", MySqlDbType.VarChar, 255); arParams[3].Direction = ParameterDirection.Input; arParams[3].Value = path.ToLower(); arParams[4] = new MySqlParameter("?SiteGuid", MySqlDbType.VarChar, 36); arParams[4].Direction = ParameterDirection.Input; arParams[4].Value = siteGuid.ToString(); int rowsAffected = Convert.ToInt32(MySqlHelper.ExecuteNonQuery( ConnectionString.GetWriteConnectionString(), sqlCommand.ToString(), arParams).ToString()); return(newPathID); }
public static bool DatabaseHelperSitesTableExists() { bool result = false; //return DatabaseHelper_TableExists("`mp_Sites`"); try { using (IDataReader reader = DBSiteSettings.GetSiteList()) { if (reader.Read()) { reader.Close(); } } // no error yet it must exist result = true; } catch { } return(result); }