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


C# Database.GetSqlStringCommand方法代码示例

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


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

示例1: CreateStoredProcedures

        public static void CreateStoredProcedures(Database db)
        {
            string sql = "create procedure RegionSelect as " +
                "select * from Region Order by RegionId";

            DbCommand command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionInsert (@RegionID int, @RegionDescription varchar(100) ) as " +
                "insert into Region values(@RegionID, @RegionDescription)";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionUpdate (@RegionID int, @RegionDescription varchar(100) ) as " +
                "update Region set RegionDescription = @RegionDescription where RegionID = @RegionID";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionDelete (@RegionID int) as " +
                "delete from Region where RegionID = @RegionID";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:26,代码来源:SqDataSetHelper.cs

示例2: CreateStoredProcedures

        public static void CreateStoredProcedures(Database db)
        {
            DbCommand command;
            string sql;

            sql = "create procedure RegionSelect (cur_OUT OUT PKGENTLIB_ARCHITECTURE.CURENTLIB_ARCHITECTURE) as " +
                "BEGIN OPEN cur_OUT FOR select * from Region Order By RegionId; END;";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionInsert (vRegionID IN Region.RegionID%TYPE, vRegionDescription IN Region.RegionDescription%TYPE) as " +
                "BEGIN insert into Region values(vRegionID, vRegionDescription); END;";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionUpdate (vRegionID IN Region.RegionID%TYPE, vRegionDescription IN Region.RegionDescription%TYPE) as " +
                "BEGIN update Region set RegionDescription = vRegionDescription where RegionID = vRegionID; END;";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);

            sql = "create procedure RegionDelete (vRegionID IN Region.RegionID%TYPE) as " +
                "BEGIN delete from Region where RegionID = vRegionID; END;";

            command = db.GetSqlStringCommand(sql);
            db.ExecuteNonQuery(command);
		}
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:29,代码来源:OracleDataSetHelper.cs

示例3: SetUp

		public void SetUp()
		{
			DatabaseProviderFactory factory = new DatabaseProviderFactory(TestConfigurationSource.CreateConfigurationSource());
			db = factory.CreateDefault();

			DbCommand insertionCommand = db.GetSqlStringCommand(insertString);
			DbCommand countCommand = db.GetSqlStringCommand(countQuery);

			baseFixture = new ExecuteNonQueryFixture(db, insertString, countQuery, insertionCommand, countCommand);
		}
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:10,代码来源:SqlExecuteNonQueryFixture.cs

示例4: SetUp

        public void SetUp()
        {
            DatabaseProviderFactory factory = new DatabaseProviderFactory(OracleTestConfigurationSource.CreateConfigurationSource());
            db = factory.Create("OracleTest");

            DbCommand insertCommand = db.GetSqlStringCommand(insertString);
            DbCommand queryCommand = db.GetSqlStringCommand(queryString);

            baseFixture = new ExecuteReaderFixture(db, insertString, insertCommand, queryString, queryCommand);
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:10,代码来源:OracleExecuteReaderFixture.cs

示例5: TestInitialize

        public void TestInitialize()
        {
            DatabaseProviderFactory factory = new DatabaseProviderFactory(TestConfigurationSource.CreateConfigurationSource());
            db = factory.CreateDefault();

            DbCommand insertCommand = db.GetSqlStringCommand(insertString);
            DbCommand queryCommand = db.GetSqlStringCommand(queryString);

            baseFixture = new ExecuteReaderFixture(db, insertString, insertCommand, queryString, queryCommand);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:10,代码来源:SqlExecuteReaderFixture.cs

示例6: SetUp

        public void SetUp()
        {
            EnvironmentHelper.AssertOracleClientIsInstalled();
            DatabaseProviderFactory factory = new DatabaseProviderFactory(OracleTestConfigurationSource.CreateConfigurationSource());
            db = factory.Create("OracleTest");

            DbCommand insertionCommand = db.GetSqlStringCommand(insertString);
            DbCommand countCommand = db.GetSqlStringCommand(countQuery);

            baseFixture = new ExecuteNonQueryFixture(db, insertString, countQuery, insertionCommand, countCommand);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:11,代码来源:OracleExecuteNonQueryFixture.cs

示例7: CreateDataAdapterCommands

		public static void CreateDataAdapterCommands(Database db, ref DbCommand insertCommand, ref DbCommand updateCommand, ref DbCommand deleteCommand)
		{
			insertCommand = db.GetSqlStringCommand("INSERT INTO Region VALUES(@RegionID, @RegionDescription)");
			updateCommand = db.GetSqlStringCommand("UPDATE region SET [email protected] WHERE [email protected]");
			deleteCommand = db.GetSqlStringCommand("DELETE FROM Region WHERE [email protected]");

			db.AddInParameter(insertCommand, "@RegionID", DbType.Int32, "RegionID", DataRowVersion.Default);
			db.AddInParameter(insertCommand, "@RegionDescription", DbType.String, "RegionDescription", DataRowVersion.Default);

			db.AddInParameter(updateCommand, "@RegionID", DbType.Int32, "RegionID", DataRowVersion.Default);
			db.AddInParameter(updateCommand, "@RegionDescription", DbType.String, "RegionDescription", DataRowVersion.Default);

			db.AddInParameter(deleteCommand, "@RegionID", DbType.Int32, "RegionID", DataRowVersion.Default);
		}
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:14,代码来源:SqlCeDataSetHelper.cs

示例8: DeleteStoredProcedures

 public static void DeleteStoredProcedures(Database db)
 {
     DbCommand command;
     string sql = "drop procedure RegionSelect";
     command = db.GetSqlStringCommand(sql);
     db.ExecuteNonQuery(command);
     sql = "drop procedure RegionInsert";
     command = db.GetSqlStringCommand(sql);
     db.ExecuteNonQuery(command);
     sql = "drop procedure RegionDelete";
     command = db.GetSqlStringCommand(sql);
     db.ExecuteNonQuery(command);
     sql = "drop procedure RegionUpdate";
     command = db.GetSqlStringCommand(sql);
     db.ExecuteNonQuery(command);
 }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:16,代码来源:OracleDataSetHelper.cs

示例9: SetUp

        public void SetUp()
        {
            DatabaseProviderFactory factory = new DatabaseProviderFactory(TestConfigurationSource.CreateConfigurationSource());
            db = factory.CreateDefault();
            DbCommand command = db.GetSqlStringCommand("Select count(*) from region");

            baseFixture = new ExecuteScalarFixture(db, command);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:8,代码来源:SqlExecuteScalarFixture.cs

示例10: SetUp

        public void SetUp()
        {
            EnvironmentHelper.AssertOracleClientIsInstalled();
            DatabaseProviderFactory factory = new DatabaseProviderFactory(OracleTestConfigurationSource.CreateConfigurationSource());
            db = factory.Create("OracleTest");
            DbCommand command = db.GetSqlStringCommand("Select count(*) from region");

            baseFixture = new ExecuteScalarFixture(db, command);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:9,代码来源:OracleExecuteScalarFixture.cs

示例11: AddTestData

 public static void AddTestData(Database db)
 {
     string sql =
         "insert into Region values (99, 'Midwest');" +
             "insert into Region values (100, 'Central Europe');" +
             "insert into Region values (101, 'Middle East');" +
             "insert into Region values (102, 'Australia')";
     DbCommand testDataInsertion = db.GetSqlStringCommand(sql);
     db.ExecuteNonQuery(testDataInsertion);
 }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:10,代码来源:SqDataSetHelper.cs

示例12: DataAccessTestsFixture

 public DataAccessTestsFixture(Database db)
 {
     this.db = db;
     dataSet = new DataSet();
     command = db.GetSqlStringCommand(sqlQuery);
 }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:6,代码来源:DataAccessTestsFixture.cs

示例13: InsertSystemLog

 private void InsertSystemLog(LogEntity entity, Database database)
 {
     DbCommand command = database.GetSqlStringCommand(string.Format(INSERT_SYSTEM_LOG_SQL, logTableName));
     database.AddInParameter(command, "GUID", DbType.Guid, entity.ExtendedProperties.ContainsKey("Guid") ? entity.ExtendedProperties["Guid"] : Guid.NewGuid());
     database.AddInParameter(command, "LogDate", DbType.DateTime, entity.ExtendedProperties.ContainsKey("LogDate") ? entity.ExtendedProperties["LogDate"] : DateTime.Now);
     database.AddInParameter(command, "LogType", DbType.Int32, entity.ExtendedProperties["LogType"]);
     database.AddInParameter(command, "LogUserLoginID", DbType.String, entity.ExtendedProperties["LogUserLoginID"]);
     database.AddInParameter(command, "LogUserIP", DbType.String, entity.ExtendedProperties["LogUserIP"]);
     database.AddInParameter(command, "LogSummary", DbType.String, GetLogSummary(entity));
     database.AddInParameter(command, "LogDescription", DbType.String, GetLogDescription(entity));
     database.AddInParameter(command, "OperationEntityCharacter", DbType.String, entity.ExtendedProperties.ContainsKey("OperationEntityCharacter") ? entity.ExtendedProperties["OperationEntityCharacter"] : DBNull.Value);
     database.AddInParameter(command, "OperationEntityGuid", DbType.Guid, entity.ExtendedProperties.ContainsKey("OperationEntityGuid") ? new Guid(entity.ExtendedProperties["OperationEntityGuid"].ToString()) : Guid.Empty);
     database.AddInParameter(command, "OperationEntityOriginalValue", DbType.String, entity.ExtendedProperties.ContainsKey("OperationEntityOriginalValue") ? entity.ExtendedProperties["OperationEntityOriginalValue"] : DBNull.Value);
     database.AddInParameter(command, "OperationEntityCurrentValue", DbType.String, entity.ExtendedProperties.ContainsKey("OperationEntityCurrentValue") ? entity.ExtendedProperties["OperationEntityCurrentValue"] : DBNull.Value);
     database.AddInParameter(command, "OperationEntityName", DbType.String, entity.ExtendedProperties.ContainsKey("OperationEntityName") ? entity.ExtendedProperties["OperationEntityName"] : DBNull.Value);
     database.AddInParameter(command, "Level", DbType.Int32, entity.ExtendedProperties["Level"]);
     database.ExecuteNonQuery(command);
 }
开发者ID:uunniie,项目名称:ctnew,代码行数:18,代码来源:SqlServerDatabaseTraceListener.cs


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