public static int GetMaxID(string FieldName, string TableName) { string strsql = "select max(" + FieldName + ")+1 from " + TableName; object obj = LineDbHelperSQL.GetSingle(strsql); if (obj == null) { return(1); } else { return(int.Parse(obj.ToString())); } }
public static bool Exists(string strSql) { object obj = LineDbHelperSQL.GetSingle(strSql); int cmdresult; if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) { cmdresult = 0; } else { cmdresult = int.Parse(obj.ToString()); } if (cmdresult == 0) { return(false); } else { return(true); } }
public void CreateProjectModel_BaseSys(string appString) { if (!String.IsNullOrEmpty(appString)) { DataSet ds = new DataSet(); string SqlText = "SELECT * FROM dbo.sys_line WHERE ID='" + appString + "'"; ds = LineDbHelperSQL.Query(SqlText); sys_line sysBaseLine = new sys_line(); if (ds != null && ds.Tables.Count > 0) { #region 保存当前选择线路的值,添加的用户的时候判断是否重复,以及区分新旧线 sysBaseLine.ID = new Guid(ds.Tables[0].Rows[0]["ID"].ToString()); sysBaseLine.Description = ds.Tables[0].Rows[0]["Description"].ToString(); sysBaseLine.DataBaseName = ds.Tables[0].Rows[0]["DataBaseName"].ToString(); sysBaseLine.DataSourceAddress = ds.Tables[0].Rows[0]["DataSourceAddress"].ToString(); sysBaseLine.IPAddress = ds.Tables[0].Rows[0]["IPAddress"].ToString(); sysBaseLine.IsActive = System.Convert.ToInt32(ds.Tables[0].Rows[0]["IsActive"].ToString()); sysBaseLine.LineName = ds.Tables[0].Rows[0]["LineName"].ToString(); sysBaseLine.PassWord = ds.Tables[0].Rows[0]["PassWord"].ToString(); sysBaseLine.UserName = ds.Tables[0].Rows[0]["UserName"].ToString(); sysBaseLine.Domain = ds.Tables[0].Rows[0]["Domain"].ToString(); #endregion } SqlText = @"INSERT dbo.sys_BaseLine_UsersLoginLog ( UserName , IpAddress , LoginTime , LineName , Desic , biz1 , biz2 ) VALUES ( '" + System.Web.HttpContext.Current.Session["UserName"].ToString() + "' , '" + System.Web.HttpContext.Current.Request.UserHostAddress + "' , '" + DateTime.Now.ToString() + "' ,'" + sysBaseLine.ID + "' , '" + sysBaseLine.LineName + "' ,'' ,'' )"; LineDbHelperSQL.ExecuteSql(SqlText); System.Web.HttpContext.Current.Session["SysBaseLine"] = sysBaseLine; } }
/// <summary> /// 表是否存在 /// </summary> /// <param name="TableName"></param> /// <returns></returns> public static bool TabExists(string TableName) { string strsql = "select count(*) from sysobjects where id = object_id(N'[" + TableName + "]') and OBJECTPROPERTY(id, N'IsUserTable') = 1"; //string strsql = "SELECT count(*) FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + TableName + "]') AND type in (N'U')"; object obj = LineDbHelperSQL.GetSingle(strsql); int cmdresult; if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) { cmdresult = 0; } else { cmdresult = int.Parse(obj.ToString()); } if (cmdresult == 0) { return(false); } else { return(true); } }