当前位置: 首页>>代码示例>>C#>>正文


C# SQL类代码示例

本文整理汇总了C#中SQL的典型用法代码示例。如果您正苦于以下问题:C# SQL类的具体用法?C# SQL怎么用?C# SQL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SQL类属于命名空间,在下文中一共展示了SQL类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Delete

 public static void Delete(string[] args, bool exit = false)
 {
     if (args.Length == 2) args = (string.Join(" ", args) + " *").Split(" ");
     if (args[1].Trim().ToLower() == "smtp") WriteLog("delete(d) smtp * 删除SMTP数据");
     if (args[1].Trim().ToLower() == "email") WriteLog("delete(d) email * 删除邮箱数据");
     WriteLog("===============================================================================");
     if (args[1].Trim().ToLower() == "smtp") {
         args = string.Join(" ", args, 2, args.Length - 2).Split(' ');
         int len = 0;
         if (args.Length == 1 && args [0] == "*")
             len = new SQL().Delete(SmtpList._).ToExec();
         else
             foreach (string s in args) {
                 string[] ss = s.Split(',');
                 if (ss.Length != 3) continue;
                 len += SmtpListHelper.DeleteByID(ss[0], ss[1].ToInt(25), ss[2]) ? 1 : 0;
             }
         WriteLog("删除影响行数:{0}", len);
         SmtpListHelper.ClearCacheAll();
     } else if (args[1].Trim().ToLower() == "email") {
         args = string.Join(" ", args, 2, args.Length - 2).Split(' ');
         int len = 0;
         if (args.Length == 1 && args [0] == "*")
             len = new SQL().Delete(EmailList._).ToExec();
         else
             foreach (string s in args) len += EmailListHelper.DeleteByID(s) ? 1 : 0;
         WriteLog("删除影响行数:{0}", len);
         EmailListHelper.ClearCacheAll();
     }
     WriteLog("END");
     Input(exit);
 }
开发者ID:jango2015,项目名称:SendEmail,代码行数:32,代码来源:Program.cs

示例2: LoadFieldsForObject

        /// --------------------------------------------------------------------------------
        /// <summary>
        /// Performs loading an object marked with the FieldMappingObjectHook attribute.
        /// Loads an object with fields or properties marked with DatabaseObjects.FieldMapping attributes
        /// with the fields from the database.
        /// </summary>
        /// <param name="objObject">
        /// The generic object that does not implement IDatabaseObject
        /// but contains FieldMapping attributes.
        /// </param>
        /// <remarks>
        /// Typically used from within the overridden LoadFields function when loading a generic object normally
        /// marked with the FieldMappingObjectHook attribute.
        /// </remarks>
        /// --------------------------------------------------------------------------------
        public static void LoadFieldsForObject(object objObject, SQL.SQLFieldValues objFields)
        {
            if (objObject == null)
                throw new ArgumentNullException();

            LoadFieldsForObject(objObject, objObject.GetType(), objFields);
        }
开发者ID:erdincay,项目名称:DatabaseObjects,代码行数:22,代码来源:DatabaseObjectUsingAttributesHelper.cs

示例3: Create

        public Exception Create(NumeroControl numControl)
        {
            //using (SqlConnection conn = sql.GetConnection())
            using (SqlConnection conn = new SQL().GetLocalConnection())
            {
                SqlCommand cmd = new SqlCommand(@"UPDATE NumeroControl SET NumControl = @NumControl WHERE AnoCorriente = @Year;", conn);

                cmd.Parameters.AddWithValue("Year", numControl.Year);

                cmd.Parameters.AddWithValue("NumControl", numControl.NumControl);

                conn.Open();

                using (SqlTransaction transaction = conn.BeginTransaction())
                {
                    cmd.Transaction = transaction;

                    try
                    {
                        cmd.ExecuteNonQuery();

                        transaction.Commit();

                        return null;
                    }

                    catch (Exception ex)
                    {
                        transaction.Rollback();

                        return ex;
                    }
                }
            }
        }
开发者ID:ijustarrived,项目名称:EXC,代码行数:35,代码来源:NumerosControlRepositorio.cs

示例4: ModifyMessage

 public static bool ModifyMessage(String UserName,String key,String values)
 {
     String commStr = "update Users set " + key + " = '" + values + "' where UserName = '" + UserName + "'";
     SQL sql = new SQL();
     bool f = sql.ExecuteNonQuery(commStr);
     sql.Dispose();
     return f;
 }
开发者ID:HIT-MSTC,项目名称:HelperOfHiters,代码行数:8,代码来源:Users.cs

示例5: ModifyMessage

 public static bool ModifyMessage(int TopicId, String key, String values)
 {
     String commStr = "update Topic set " + key + " = '" + values + "' where id = " + TopicId;
     SQL sql = new SQL();
     bool f = sql.ExecuteNonQuery(commStr);
     sql.Dispose();
     return f;
 }
开发者ID:HIT-MSTC,项目名称:HelperOfHiters,代码行数:8,代码来源:Topic.cs

示例6: GetTopicAnswer

 public static String GetTopicAnswer(int TopicId)
 {
     String commStr = "select * from Answer where TopicId = " + TopicId;
     SQL sql = new SQL();
     String ans = sql.ExecuteXml(commStr);
     sql.Dispose();
     return ans;
 }
开发者ID:HIT-MSTC,项目名称:HelperOfHiters,代码行数:8,代码来源:Answer.cs

示例7: Should_Return_Simple_Delete_From_Table

        public void Should_Return_Simple_Delete_From_Table()
        {
            var expected = "DELETE FROM table";
            var sql = new SQL();
            sql.Delete().From("table");

            Assert.AreEqual(expected, sql.ToString());
        }
开发者ID:seymourpoler,项目名称:PetProjects,代码行数:8,代码来源:Squel.Delete.Test.cs

示例8: Register

 public static bool Register(String UserName,String Password)
 {
     String commStr = "insert into Users values ('" + UserName + "','" + Password + "','','','',0,'')";
     SQL sql = new SQL();
     bool f = sql.ExecuteNonQuery(commStr);
     sql.Dispose();
     return f;
 }
开发者ID:HIT-MSTC,项目名称:HelperOfHiters,代码行数:8,代码来源:Users.cs

示例9: GetRecommandTopic

 public static String GetRecommandTopic(String Part)
 {
     String commStr = "select * from Topic where Recommand = 1 and Part in ('" + Part.Substring(0,Part.Length-1).Replace(",","','") + "')";
     SQL sql = new SQL();
     String ans = sql.ExecuteXml(commStr);
     sql.Dispose();
     return ans;
 }
开发者ID:HIT-MSTC,项目名称:HelperOfHiters,代码行数:8,代码来源:Topic.cs

示例10: GetAllRecommandTopic

 public static String GetAllRecommandTopic()
 {
     String commStr = "select * from Topic where Recommand = 1";
     SQL sql = new SQL();
     String ans = sql.ExecuteXml(commStr);
     sql.Dispose();
     return ans;
 }
开发者ID:HIT-MSTC,项目名称:HelperOfHiters,代码行数:8,代码来源:Topic.cs

示例11: GetUserTopic

 public static String GetUserTopic(String Author)
 {
     String commStr = "select * from Topic where Author = '" + Author + "'";
     SQL sql = new SQL();
     String ans = sql.ExecuteXml(commStr);
     sql.Dispose();
     return ans;
 }
开发者ID:HIT-MSTC,项目名称:HelperOfHiters,代码行数:8,代码来源:Topic.cs

示例12: DeleteFocusPart

 public static bool DeleteFocusPart(String UserName, String Part)
 {
     String commStr = "update Users set FocusPart = '" + GetMessage(UserName, "FocusPart").Replace(Part+",","") + "' where UserName = '" + UserName + "'";
     SQL sql = new SQL();
     bool f = sql.ExecuteNonQuery(commStr);
     sql.Dispose();
     return f;
 }
开发者ID:HIT-MSTC,项目名称:HelperOfHiters,代码行数:8,代码来源:Users.cs

示例13: GetXml

 public static String GetXml(String UserName)
 {
     String commStr = "select UserName,Email,StudentNumber,Major,AccumulatePoint,FocusPart from Users where UserName = '" + UserName + "'";
     SQL sql = new SQL();
     String ans = sql.ExecuteXml(commStr);
     sql.Dispose();
     return ans;
 }
开发者ID:HIT-MSTC,项目名称:HelperOfHiters,代码行数:8,代码来源:Users.cs

示例14: GetXml

 public static String GetXml(int id)
 {
     String commStr = "select * from Topic where id = " + id;
     SQL sql = new SQL();
     String ans = sql.ExecuteXml(commStr);
     sql.Dispose();
     return ans;
 }
开发者ID:HIT-MSTC,项目名称:HelperOfHiters,代码行数:8,代码来源:Topic.cs

示例15: AddPoint

 public static bool AddPoint(String UserName, int Point)
 {
     String commStr = "update Users set AccumulatePoint = " + (int.Parse(GetMessage(UserName, "AccumulatePoint"))+Point) + " where UserName = '" + UserName + "'";
     SQL sql = new SQL();
     bool f = sql.ExecuteNonQuery(commStr);
     sql.Dispose();
     return f;
 }
开发者ID:HIT-MSTC,项目名称:HelperOfHiters,代码行数:8,代码来源:Users.cs


注:本文中的SQL类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。