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


C# SQLHelper.ExecuteNonQuery方法代码示例

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


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

示例1: Dispose

 public void Dispose()
 {
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("ALTER DATABASE TestDatabase SET OFFLINE WITH ROLLBACK IMMEDIATE", "Data Source=localhost;Initial Catalog=master;Integrated Security=SSPI;Pooling=false", CommandType.Text))
     {
         Helper.ExecuteNonQuery();
         Helper.Command = "ALTER DATABASE TestDatabase SET ONLINE";
         Helper.ExecuteNonQuery();
         Helper.Command = "DROP DATABASE TestDatabase";
         Helper.ExecuteNonQuery();
     }
 }
开发者ID:gwilkinson,项目名称:Craig-s-Utility-Library,代码行数:11,代码来源:SQLServer.cs

示例2: Mapping

        public Mapping()
        {
            using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("Create Database TestDatabase", "Data Source=localhost;Integrated Security=SSPI;Pooling=false", CommandType.Text))
            {
                Helper.ExecuteNonQuery();

            }
            using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("Create Table TestTable(ID_ INT PRIMARY KEY IDENTITY,StringValue_ NVARCHAR(100),LongValue_ BIGINT,BoolValue_ BIT,FloatValue_ FLOAT,StringMaxValue_ NVARCHAR(MAX))", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
            {
                Helper.ExecuteNonQuery();
            }
        }
开发者ID:AngelMarquez,项目名称:Craig-s-Utility-Library,代码行数:12,代码来源:Mapping.cs

示例3: SQLHelper

        public SQLHelper()
        {
            using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("Create Database TestDatabase", "Data Source=localhost;Integrated Security=SSPI;Pooling=false", CommandType.Text))
            {
                Helper.ExecuteNonQuery();

            }
            using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("Create Table TestTable(ID INT PRIMARY KEY IDENTITY,StringValue1 NVARCHAR(100),StringValue2 NVARCHAR(MAX),BigIntValue BIGINT,BitValue BIT,DecimalValue DECIMAL(12,6),FloatValue FLOAT,DateTimeValue DATETIME,GUIDValue UNIQUEIDENTIFIER)", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
            {
                Helper.ExecuteNonQuery();
            }
        }
开发者ID:jpsullivan,项目名称:Craig-s-Utility-Library,代码行数:12,代码来源:SQLHelper.cs

示例4: CreateDatabase

 public void CreateDatabase()
 {
     Database Database = new Database("TestDatabase");
     Table TestTable = Database.AddTable("TestTable");
     TestTable.AddColumn<string>("ID_", DbType.Int32);
     TestTable.AddColumn<string>("Value1", DbType.String, 100);
     TestTable.AddColumn<string>("Value2", DbType.Double);
     Utilities.SQL.SQLServer.SQLServer.CreateDatabase(Database, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false");
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("insert into TestTable(ID_,Value1,Value2) VALUES (@ID_,@Value1,@Value2)", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
     {
         Helper.AddParameter<int>("@ID_", 1);
         Helper.AddParameter<string>("@Value1", "Test String");
         Helper.AddParameter<float>("@Value2", 3.0f);
         Assert.Equal(1, Helper.ExecuteNonQuery());
     }
 }
开发者ID:Adilson,项目名称:Craig-s-Utility-Library,代码行数:16,代码来源:SQLServer.cs

示例5: Update

 public void Update()
 {
     Guid TempGuid = Guid.NewGuid();
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("insert into TestTable(StringValue1,StringValue2,BigIntValue,BitValue,DecimalValue,FloatValue,DateTimeValue,GUIDValue) VALUES (@StringValue1,@StringValue2,@BigIntValue,@BitValue,@DecimalValue,@FloatValue,@DateTimeValue,@GUIDValue)", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
     {
         Helper.AddParameter<string>("@StringValue1", "Test");
         Helper.AddParameter<string>("@StringValue2", "Test");
         Helper.AddParameter<long>("@BigIntValue", 123);
         Helper.AddParameter<bool>("@BitValue", false);
         Helper.AddParameter<decimal>("@DecimalValue", 1234);
         Helper.AddParameter<float>("@FloatValue", 12345);
         Helper.AddParameter<Guid>("@GUIDValue", Guid.NewGuid());
         Helper.AddParameter<DateTime>("@DateTimeValue", new DateTime(1999, 1, 1));
         Helper.ExecuteNonQuery();
     }
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("update TestTable set [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
     {
         Helper.AddParameter<string>("@StringValue1", "Test String");
         Helper.AddParameter<string>("@StringValue2", "Test String");
         Helper.AddParameter<long>("@BigIntValue", 12345);
         Helper.AddParameter<bool>("@BitValue", true);
         Helper.AddParameter<decimal>("@DecimalValue", 1234.5678m);
         Helper.AddParameter<float>("@FloatValue", 12345.6534f);
         Helper.AddParameter<Guid>("@GUIDValue", TempGuid);
         Helper.AddParameter<DateTime>("@DateTimeValue", new DateTime(1999, 12, 31));
         Helper.ExecuteNonQuery();
     }
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT * FROM TestTable", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
     {
         Helper.ExecuteReader();
         if (Helper.Read())
         {
             Assert.Equal("Test String", Helper.GetParameter<string>("StringValue1", ""));
             Assert.Equal("Test String", Helper.GetParameter<string>("StringValue2", ""));
             Assert.Equal(12345, Helper.GetParameter<long>("BigIntValue", 0));
             Assert.Equal(true, Helper.GetParameter<bool>("BitValue", false));
             Assert.Equal(1234.5678m, Helper.GetParameter<decimal>("DecimalValue", 0));
             Assert.Equal(12345.6534f, Helper.GetParameter<float>("FloatValue", 0));
             Assert.Equal(TempGuid, Helper.GetParameter<Guid>("GUIDValue", Guid.Empty));
             Assert.Equal(new DateTime(1999, 12, 31), Helper.GetParameter<DateTime>("DateTimeValue", DateTime.Now));
         }
         else
         {
             Assert.Fail("Nothing was inserted");
         }
     }
 }
开发者ID:jpsullivan,项目名称:Craig-s-Utility-Library,代码行数:47,代码来源:SQLHelper.cs

示例6: OutputParamter

 public void OutputParamter()
 {
     Guid TempGuid = Guid.NewGuid();
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("insert into TestTable(StringValue1,StringValue2,BigIntValue,BitValue,DecimalValue,FloatValue,DateTimeValue,GUIDValue) VALUES (@StringValue1,@StringValue2,@BigIntValue,@BitValue,@DecimalValue,@FloatValue,@DateTimeValue,@GUIDValue)", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
     {
         Helper.AddParameter<string>("@StringValue1", "Test String");
         Helper.AddParameter<string>("@StringValue2", "Test String");
         Helper.AddParameter<long>("@BigIntValue", 12345);
         Helper.AddParameter<bool>("@BitValue", true);
         Helper.AddParameter<decimal>("@DecimalValue", 1234.5678m);
         Helper.AddParameter<float>("@FloatValue", 12345.6534f);
         Helper.AddParameter<Guid>("@GUIDValue", TempGuid);
         Helper.AddParameter<DateTime>("@DateTimeValue", new DateTime(1999, 12, 31));
         Helper.ExecuteNonQuery();
     }
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SET @ASD=12345", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
     {
         Helper.AddParameter<long>("@ASD", Direction: ParameterDirection.Output);
         Helper.ExecuteNonQuery();
         Assert.Equal(12345, Helper.GetParameter<long>("@ASD", 0, ParameterDirection.Output));
     }
 }
开发者ID:jpsullivan,项目名称:Craig-s-Utility-Library,代码行数:22,代码来源:SQLHelper.cs

示例7: Delete

 public void Delete()
 {
     Guid TempGuid = Guid.NewGuid();
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("insert into TestTable(StringValue1,StringValue2,BigIntValue,BitValue,DecimalValue,FloatValue,DateTimeValue,GUIDValue) VALUES (@StringValue1,@StringValue2,@BigIntValue,@BitValue,@DecimalValue,@FloatValue,@DateTimeValue,@GUIDValue)", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
     {
         Helper.AddParameter<string>("@StringValue1", "Test String");
         Helper.AddParameter<string>("@StringValue2", "Test String");
         Helper.AddParameter<long>("@BigIntValue", 12345);
         Helper.AddParameter<bool>("@BitValue", true);
         Helper.AddParameter<decimal>("@DecimalValue", 1234.5678m);
         Helper.AddParameter<float>("@FloatValue", 12345.6534f);
         Helper.AddParameter<Guid>("@GUIDValue", TempGuid);
         Helper.AddParameter<DateTime>("@DateTimeValue", new DateTime(1999, 12, 31));
         Helper.ExecuteNonQuery();
     }
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("delete from TestTable where @ID=ID", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
     {
         Helper.AddParameter<int>("@ID", 1);
         Helper.ExecuteNonQuery();
     }
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT * FROM TestTable", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
     {
         Helper.ExecuteReader();
         if (Helper.Read())
         {
             Assert.Fail("Nothing was deleted");
         }
     }
 }
开发者ID:jpsullivan,项目名称:Craig-s-Utility-Library,代码行数:29,代码来源:SQLHelper.cs

示例8: CommandInsertNullString

 public void CommandInsertNullString()
 {
     Guid TempGuid = Guid.NewGuid();
     Utilities.SQL.Command TempCommand = new Utilities.SQL.Command("insert into TestTable(StringValue1,StringValue2,BigIntValue,BitValue,DecimalValue,FloatValue,DateTimeValue,GUIDValue) VALUES (@0,@1,@2,@3,@4,@5,@6,@7)", CommandType.Text, "Test String", null, 12345, true, 1234.5678m, 12345.6534f, new DateTime(1999, 12, 31), TempGuid);
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper(TempCommand, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"))
     {
         Helper.ExecuteNonQuery();
     }
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT * FROM TestTable", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
     {
         Helper.ExecuteReader();
         if (Helper.Read())
         {
             Assert.Equal("Test String", Helper.GetParameter<string>("StringValue1", ""));
             Assert.Equal("This is a null string", Helper.GetParameter<string>("StringValue2", "This is a null string"));
             Assert.Equal(12345, Helper.GetParameter<long>("BigIntValue", 0));
             Assert.Equal(true, Helper.GetParameter<bool>("BitValue", false));
             Assert.Equal(1234.5678m, Helper.GetParameter<decimal>("DecimalValue", 0));
             Assert.Equal(12345.6534f, Helper.GetParameter<float>("FloatValue", 0));
             Assert.Equal(TempGuid, Helper.GetParameter<Guid>("GUIDValue", Guid.Empty));
             Assert.Equal(new DateTime(1999, 12, 31), Helper.GetParameter<DateTime>("DateTimeValue", DateTime.Now));
         }
         else
         {
             Assert.Fail("Nothing was inserted");
         }
     }
 }
开发者ID:jpsullivan,项目名称:Craig-s-Utility-Library,代码行数:28,代码来源:SQLHelper.cs

示例9: UpdateDatabase

 public void UpdateDatabase()
 {
     Database Database = new Database("TestDatabase");
     Table TestTable = Database.AddTable("TestTable");
     TestTable.AddColumn<string>("ID_", DbType.Int32);
     TestTable.AddColumn<string>("Value1", DbType.String, 100);
     TestTable.AddColumn<string>("Value2", DbType.Double);
     Utilities.SQL.SQLServer.SQLServer.CreateDatabase(Database, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false");
     Database Database2 = new Database("TestDatabase");
     TestTable = Database2.AddTable("TestTable");
     TestTable.AddColumn<string>("ID_", DbType.Int32);
     TestTable.AddColumn<string>("Value1", DbType.String, 100);
     TestTable.AddColumn<string>("Value2", DbType.Double);
     TestTable.AddColumn<string>("Value3", DbType.Boolean);
     Utilities.SQL.SQLServer.SQLServer.UpdateDatabase(Database2, Database, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false");
     using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("insert into TestTable(ID_,Value1,Value2,Value3) VALUES (@ID_,@Value1,@Value2,@Value3)", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text))
     {
         Helper.AddParameter<int>("@ID_", 1);
         Helper.AddParameter<string>("@Value1", "Test String");
         Helper.AddParameter<float>("@Value2", 3.0f);
         Helper.AddParameter<bool>("@Value3", true);
         Assert.Equal(1, Helper.ExecuteNonQuery());
     }
     Database Database3 = Utilities.SQL.SQLServer.SQLServer.GetDatabaseStructure("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false");
     Assert.Equal(Database2.Tables.First().Name, Database3.Tables.First().Name);
     Assert.Equal(Database2.Tables.First().Columns.Count, Database3.Tables.First().Columns.Count);
     Assert.Equal(DbType.Int32, Database3.Tables.First().Columns.First(x => x.Name == "ID_").DataType);
     Assert.Equal(DbType.String, Database3.Tables.First().Columns.First(x => x.Name == "Value1").DataType);
     Assert.Equal(DbType.Double, Database3.Tables.First().Columns.First(x => x.Name == "Value2").DataType);
     Assert.Equal(100, Database3.Tables.First().Columns.First(x => x.Name == "Value1").Length);
     Assert.Equal(4, Database3.Tables.First().Columns.First(x => x.Name == "ID_").Length);
     Assert.Equal(8, Database3.Tables.First().Columns.First(x => x.Name == "Value2").Length);
 }
开发者ID:Adilson,项目名称:Craig-s-Utility-Library,代码行数:33,代码来源:SQLServer.cs


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