• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SQL类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetAllAirDefenseInfo4android

 public string GetAllAirDefenseInfo4android(string GUID)
 {
     SQL sql = new SQL();
     if (sql.checkGUID(GUID))
         return sql.getinfo();
     else
         return "[email protected]未授权的访问@NONE";
 }
开发者ID:wongtseng,项目名称:RFGIS,代码行数:8,代码来源:Service1.asmx.cs


示例17: GetRecommandAnswer

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


示例18: CancelRecommandAnswer

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


示例19: GetPartTopic

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


示例20: Login

 public static bool Login(String UserName,String Password)
 {
     String commStr = "select * from Users where UserName = '" + UserName + "' and Password = '" + Password + "'";
     SQL sql = new SQL();
     bool f = sql.ExecuteReader(commStr).Read();
     sql.Dispose();
     return f;
 }
开发者ID:HIT-MSTC,项目名称:HelperOfHiters,代码行数:8,代码来源:Users.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SQLDB类代码示例发布时间:2022-05-24
下一篇:
C# SPoint类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap