public static bool HasChild(string QueryString) { SqlConnection _conn = new SqlConnection(EMSConFunc.ConString()); int nHas = 0; SqlCommand cmd = new SqlCommand(QueryString, _conn); if (_conn.State == ConnectionState.Open) { } else { cmd.Connection.Open(); } object bIsExist = cmd.ExecuteScalar(); cmd.Connection.Close(); nHas = Convert.ToInt32(bIsExist); if (nHas > 0) { return(true); } else { return(false); } }
public static void ExeNonQuery(string QueryString) { SqlConnection _conn = new SqlConnection(EMSConFunc.ConString()); SqlCommand cmd = new SqlCommand(QueryString, _conn); if (_conn.State == ConnectionState.Open) { } else { cmd.Connection.Open(); } cmd.ExecuteNonQuery(); cmd.Dispose(); cmd.Connection.Close(); }
public static int ExeRetInt(string QueryString) { int nHas = 0; SqlConnection _conn = new SqlConnection(EMSConFunc.ConString()); SqlCommand cmd = new SqlCommand(QueryString, _conn); if (_conn.State == ConnectionState.Open) { } else { cmd.Connection.Open(); } object bIsExist = cmd.ExecuteScalar(); cmd.Connection.Close(); nHas = Convert.ToInt32(bIsExist); return(nHas); }