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


C# SQLHelper.ExecuteNonQuery方法代码示例

本文整理汇总了C#中SQLHelper.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# SQLHelper.ExecuteNonQuery方法的具体用法?C# SQLHelper.ExecuteNonQuery怎么用?C# SQLHelper.ExecuteNonQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQLHelper的用法示例。


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

示例1: CreateDatabase

 /// <summary>
 /// Creates a database out of the structure it is given
 /// </summary>
 /// <param name="Database">Database structure</param>
 /// <param name="ConnectionString">The connection string to the database's location</param>
 public static void CreateDatabase(Database Database,string ConnectionString)
 {
     try
     {
         string Command = BuildCommands(Database);
         string[] Splitter = { "\n" };
         string[] Commands = Command.Split(Splitter, StringSplitOptions.RemoveEmptyEntries);
         string DatabaseConnectionString = Regex.Replace(ConnectionString, "Initial Catalog=(.*?;)", "");
         using (SQLHelper Helper = new SQLHelper(Commands[0], DatabaseConnectionString, CommandType.Text))
         {
             try
             {
                 Helper.Open();
                 Helper.ExecuteNonQuery();
             }
             catch { throw; }
             finally { Helper.Close(); }
         }
         for (int x = 1; x < Commands.Length; ++x)
         {
             using (SQLHelper Helper = new SQLHelper(Commands[x], ConnectionString, CommandType.Text))
             {
                 try
                 {
                     Helper.Open();
                     Helper.ExecuteNonQuery();
                 }
                 catch { throw; }
                 finally { Helper.Close(); }
             }
         }
     }
     catch { throw; }
 }
开发者ID:pengyancai,项目名称:cs-util,代码行数:39,代码来源:SQLServer.cs

示例2: CreateDatabase

 /// <summary>
 /// Creates a database out of the structure it is given
 /// </summary>
 /// <param name="Database">Database structure</param>
 /// <param name="ConnectionString">The connection string to the database's location</param>
 public static void CreateDatabase(Database Database, string ConnectionString)
 {
     string Command = BuildCommands(Database);
     string[] Splitter = { "\n" };
     string[] Commands = Command.Split(Splitter, StringSplitOptions.RemoveEmptyEntries);
     ConnectionString = Regex.Replace(ConnectionString, "Pooling=(.*?;)", "", RegexOptions.IgnoreCase) + ";Pooling=false;";
     string DatabaseConnectionString = Regex.Replace(ConnectionString, "Initial Catalog=(.*?;)", "", RegexOptions.IgnoreCase);
     using (SQLHelper Helper = new SQLHelper(Commands[0], DatabaseConnectionString, CommandType.Text))
     {
         Helper.ExecuteNonQuery();
     }
     using (SQLHelper Helper = new SQLHelper("", ConnectionString, CommandType.Text))
     {
         try
         {
             Helper.BeginTransaction();
             for (int x = 1; x < Commands.Length; ++x)
             {
                 Helper.Command = Commands[x];
                 Helper.ExecuteNonQuery();
             }
             Helper.Commit();
         }
         catch { Helper.Rollback(); throw; }
     }
 }
开发者ID:yiwayhb,项目名称:Craig-s-Utility-Library,代码行数:31,代码来源:SQLServer.cs

示例3: Delete

 public void Delete(SQLHelper sqlHelper, int ID)
 {
     string sql = string.Empty;
     try
     {
         sql = sqlHelper.MakeSQL(@"DELETE SIMREG_REQUESTEDBY WHERE REQUESTEDBYID=$n", ID);
         sqlHelper.ExecuteNonQuery(sql);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
开发者ID:raselahmmedgit,项目名称:simreg-sample,代码行数:13,代码来源:DASIMREG_REQUESTEDBY.cs

示例4: CreateDatabase

 /// <summary>
 /// Creates a database out of the structure it is given
 /// </summary>
 /// <param name="Database">Database structure</param>
 /// <param name="ConnectionString">The connection string to the database's location</param>
 public static void CreateDatabase(Database Database, string ConnectionString)
 {
     string Command = BuildCommands(Database);
     string[] Splitter = { "\n" };
     string[] Commands = Command.Split(Splitter, StringSplitOptions.RemoveEmptyEntries);
     ConnectionString = Regex.Replace(ConnectionString, "Pooling=(.*?;)", "", RegexOptions.IgnoreCase) + ";Pooling=false;";
     string DatabaseConnectionString = Regex.Replace(ConnectionString, "Initial Catalog=(.*?;)", "", RegexOptions.IgnoreCase);
     using (SQLHelper Helper = new SQLHelper(Commands[0], DatabaseConnectionString, CommandType.Text))
     {
         Helper.ExecuteNonQuery();
     }
     using (SQLHelper Helper = new SQLHelper("", ConnectionString, CommandType.Text))
     {
         IBatchCommand Batcher = Helper.Batch();
         for (int x = 1; x < Commands.Length; ++x)
         {
             if (Commands[x].Contains("CREATE TRIGGER") || Commands[x].Contains("CREATE FUNCTION"))
             {
                 if (Batcher.CommandCount > 0)
                 {
                     Helper.ExecuteNonQuery();
                     Batcher = Helper.Batch();
                 }
                 Batcher.AddCommand(Commands[x], CommandType.Text);
                 if (x < Commands.Length - 1)
                 {
                     Helper.ExecuteNonQuery();
                     Batcher = Helper.Batch();
                 }
             }
             else
             {
                 Batcher.AddCommand(Commands[x], CommandType.Text);
             }
         }
         Helper.ExecuteNonQuery();
     }
 }
开发者ID:AngelMarquez,项目名称:Craig-s-Utility-Library,代码行数:43,代码来源:SQLServer.cs

示例5: UpdateDatabase

 /// <summary>
 /// Updates a database (only adds new fields, tables, etc. does not delete old fields)
 /// </summary>
 /// <param name="DesiredDatabase">The desired structure of the database</param>
 /// <param name="CurrentDatabase">The current database structure</param>
 /// <param name="ConnectionString">Connection string to the database</param>
 public static void UpdateDatabase(Database DesiredDatabase, Database CurrentDatabase, string ConnectionString)
 {
     if (CurrentDatabase == null)
     {
         CreateDatabase(DesiredDatabase, ConnectionString);
         return;
     }
     string Command = BuildCommands(DesiredDatabase, CurrentDatabase);
     string[] Splitter = { "\n" };
     string[] Commands = Command.Split(Splitter, StringSplitOptions.RemoveEmptyEntries);
     ConnectionString = Regex.Replace(ConnectionString, "Pooling=(.*?;)", "", RegexOptions.IgnoreCase) + ";Pooling=false;";
     using (SQLHelper Helper = new SQLHelper("", ConnectionString, CommandType.Text))
     {
         try
         {
             Helper.BeginTransaction();
             for (int x = 0; x < Commands.Length; ++x)
             {
                 Helper.Command = Commands[x];
                 Helper.ExecuteNonQuery();
             }
             Helper.Commit();
         }
         catch { Helper.Rollback(); throw; }
     }
 }
开发者ID:yiwayhb,项目名称:Craig-s-Utility-Library,代码行数:32,代码来源:SQLServer.cs

示例6: Save

        public void Save(SQLHelper sqlHelper, BESIMREG_REQUESTEDBY entity)
        {
            string sql = string.Empty;
            try
            {
                if (entity.IsNew)
                {
                    // update tblTableCode
                    DATableCode daTableCode = new DATableCode();
                    //entity.REQUESTEDBYID = daTableCode.GetTableId(sqlHelper, "REQUESTEDBYID", "SIMREG_REQUESTEDBY");

                    sql = sqlHelper.MakeSQL(@"INSERT INTO SIMREG_REQUESTEDBY(REQUESTEDBYID, TITLE, IDATE, IUSER, EDATE, EUSER)"
                                            + " VALUES(SQ_SIMREG_REQUESTEDBYID.Nextval, $s, SYSDATE, $n, SYSDATE, $n)",
                        //entity.REQUESTEDBYID,
                                            entity.TITLE,
                                            //entity.IDATE,
                                            entity.IUSER,
                                            //entity.EDATE,
                                            entity.EUSER);
                }
                else
                {
                    sql = sqlHelper.MakeSQL(@"UPDATE SIMREG_REQUESTEDBY SET TITLE=$s, EDATE=SYSDATE, EUSER=$n WHERE REQUESTEDBYID=$n",
                                            entity.TITLE,
                                            //entity.EDATE,
                                            entity.EUSER,
                                            entity.REQUESTEDBYID);
                }

                sqlHelper.ExecuteNonQuery(sql);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
开发者ID:raselahmmedgit,项目名称:simreg-sample,代码行数:36,代码来源:DASIMREG_REQUESTEDBY.cs

示例7: Save

        public void Save(SQLHelper sqlHelper, BESIMREG_NEWFORM entity)
        {
            string sql = string.Empty;
            try
            {
                if (entity.IsNew)
                {
                    // update tblTableCode
                    DATableCode daTableCode = new DATableCode();
                    //entity.ID = daTableCode.GetTableId(sqlHelper, "ID", "SIMREG_NEWFORM");

                    sql = sqlHelper.MakeSQL(@"INSERT INTO SIMREG_NEWFORM(ID, MSISDNTITLE, REQUESTEDDATE, REQUESTEDBYID, REQUESTEDTYPEID, DELIVEREDBYDATE, DELIVEREDBYID, IDATE, IUSER, EDATE, EUSER)"
                                            + " VALUES(SQ_SIMREG_NEWFORMID.Nextval, $s, $d, $n, $n, $d, $n, SYSDATE, $n, SYSDATE, $n)",
                        //entity.ID,
                        //entity.MSISDNID,
                                            entity.MSISDNTITLE,
                                            entity.REQUESTEDDATE,
                                            entity.REQUESTEDBYID,
                                            entity.REQUESTEDTYPEID,
                                            entity.DELIVEREDBYDATE,
                                            entity.DELIVEREDBYID,
                        //entity.IDATE,
                                            entity.IUSER,
                        //entity.EDATE,
                                            entity.EUSER);
                }
                else
                {
                    sql = sqlHelper.MakeSQL(@"UPDATE SIMREG_NEWFORM SET MSISDNTITLE=$s, REQUESTEDDATE=$d, REQUESTEDBYID=$n, REQUESTEDTYPEID=$n, DELIVEREDBYDATE=$d, DELIVEREDBYID=$n, EDATE=SYSDATE, EUSER=$n WHERE ID=$n",
                        //entity.MSISDNID,
                                            entity.MSISDNTITLE,
                                            entity.REQUESTEDDATE,
                                            entity.REQUESTEDBYID,
                                            entity.REQUESTEDTYPEID,
                                            entity.DELIVEREDBYDATE,
                                            entity.DELIVEREDBYID,
                        //entity.EDATE,
                                            entity.EUSER,
                                            entity.ID);
                }

                sqlHelper.ExecuteNonQuery(sql);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
开发者ID:raselahmmedgit,项目名称:simreg-sample,代码行数:48,代码来源:DASIMREG_NEWFORM.cs

示例8: UpdateDatabase

 /// <summary>
 /// Updates a database (only adds new fields, tables, etc. does not delete old fields)
 /// </summary>
 /// <param name="DesiredDatabase">The desired structure of the database</param>
 /// <param name="CurrentDatabase">The current database structure</param>
 /// <param name="ConnectionString">Connection string to the database</param>
 public static void UpdateDatabase(Database DesiredDatabase, Database CurrentDatabase, string ConnectionString)
 {
     try
     {
         if (CurrentDatabase == null)
         {
             CreateDatabase(DesiredDatabase, ConnectionString);
             return;
         }
         string Command = BuildCommands(DesiredDatabase, CurrentDatabase);
         string[] Splitter = { "\n" };
         string[] Commands = Command.Split(Splitter, StringSplitOptions.RemoveEmptyEntries);
         for (int x = 0; x < Commands.Length; ++x)
         {
             using (SQLHelper Helper = new SQLHelper(Commands[x], ConnectionString, CommandType.Text))
             {
                 try
                 {
                     Helper.Open();
                     Helper.ExecuteNonQuery();
                 }
                 catch { throw; }
                 finally { Helper.Close(); }
             }
         }
     }
     catch { throw; }
 }
开发者ID:pengyancai,项目名称:cs-util,代码行数:34,代码来源:SQLServer.cs

示例9: Save

        public void Save(SQLHelper sqlHelper, BESIMREG_DOMAINUSER entity)
        {
            try
            {
                string sql = string.Empty;

                if (entity.IsNew)
                {
                    sql = sqlHelper.MakeSQL("INSERT INTO tbldomainuser1(userid, loginname, username, IsDeleted, IsActive, CreatedBy,"
                        + " CreatedDate, Serial) VALUES ($n, $s, $s, $b, $b, $n, $D, $n)", entity.userid, entity.loginname,
                         entity.username);

                }
                else
                {
                    sql = sqlHelper.MakeSQL("UPDATE tbldomainuser1 SET userid = $n, loginname = $s, username = $s, UpdatedDate = $D,"
                        + " UpdatedBy = $n"
                        + " WHERE userid=$n", entity.userid, entity.loginname, entity.username, entity.EDATE,
                         entity.EUSER, entity.userid);
                }

                sqlHelper.ExecuteNonQuery(sql);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
开发者ID:raselahmmedgit,项目名称:simreg-sample,代码行数:28,代码来源:DASIMREG_DOMAINUSER.cs


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