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

C# SqlDatabase类代码示例

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

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



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

示例1: sinhvienMainForm_Load

        private void sinhvienMainForm_Load(object sender, EventArgs e)
        {
            //lopItems.Add(new Lop() {
            //    LopId = 1,
            //    TenLop = "cntt k37",
            //    GVCN = "A"
            //});
            //lopItems.Add(new Lop()
            //{
            //    LopId = 2,
            //    TenLop = "cntt k38",
            //    GVCN = "B"
            //});
            //lopItems.Add(new Lop()
            //{
            //    LopId = 3,
            //    TenLop = "cntt k39",
            //    GVCN = "C"
            //});
            var db = new SqlDatabase();
            lopItems = db.GetList<Lop>("select * from lop");

            //lopItems = DataExtensions.GetList<Lop>(db, "select * from Lop");

            lopBindingSource.DataSource = lopItems;
            sinhvienBindingSource.DataSource = data;
        }
开发者ID:stupidguy176,项目名称:Ngungu,代码行数:27,代码来源:sinhvienMainForm.cs


示例2: DoGet

        protected override void DoGet()
        {
            chkDelFlag.Enabled = DbHelper.isAdmin(Page.User.Identity.Name);

            action = Request["Action"];
            txtBuildingId.Text = Request["Id"];

            hidAction.Value = action;

            SqlDatabase db = new SqlDatabase();
            if (action == "Edit")
            {
                lblHeader.Text = "Thông Tin Chi Tiết " + title;
                btnRegister.Text = "Cập Nhật";
                btnCancel.Text = "Đóng";
                btnRegister.CommandName = "Edit";
                if (!IsPostBack)
                {
                    LoadData();
                }
            }
            else // Add new case
            {
                //chkDelFlag.Checked = true;
                //lblHeader.Text = "Thêm Mới " + title;
                //btnRegister.Text = "Thêm Mới";
                //btnRegister.CommandName = "Register";
                //btnCancel.Text = "Đóng";
            }
        }
开发者ID:tuankyo,项目名称:QLTN,代码行数:30,代码来源:BuildingEdit.aspx+(1).cs


示例3: DoLog

 /// <summary>
 /// Override to specify how the trace entry should be logged.
 /// </summary>
 /// <param name="item">Trace entry</param>
 protected override void DoLog(TraceLogItem item)
 {
     using (var db = new SqlDatabase(_sqlConnectionOrName))
     {
         var logRecord = new TraceRecord
             {
                 // ReSharper disable PossibleInvalidOperationException
                 Timestamp = item.TimestampUtc.Value,
                 // ReSharper restore PossibleInvalidOperationException
                 Type = (int)item.Type,
                 OperationType = item.OperationType,
                 SessionId = item.SessionId,
                 BusinessTransactionId = item.BusinessTransactionId,
                 OperationInstanceId = item.OperationInstanceId,
                 TenantId = item.TenantId,
                 Message = item.Message,
                 DetailedMessage = item.DetailedMessage,
                 ServerName = item.ServerName,
                 // ReSharper disable PossibleInvalidOperationException
                 ThreadId = item.ThreadId.Value
                 // ReSharper restore PossibleInvalidOperationException
             };
         db.Insert(logRecord);
     }
 }
开发者ID:gergopados,项目名称:Seemplest,代码行数:29,代码来源:SqlTableTraceLogger.cs


示例4: NotQueuedSanityCheckup

 private static void NotQueuedSanityCheckup()
 {
     lock (_dbLock)
     {
         using (var db = new SqlDatabase<NotQueuedEntry>(NotQueuedLocation))
         {
             const int secondsInWeek = 604800;
             var nowTime = Time.GetNowUnixTimestamp();
             var truncateTime = nowTime - secondsInWeek;
             var removing = false;
             var bubblesToTruncate = new List<NotQueuedEntry>();
             foreach (var possibleBubble in db.Store.Where(x => x.Time < truncateTime))
             {
                 if (!removing)
                 {
                     Utils.DebugPrint("Pruning not queued bubbles database. Some bubbles are too old!");
                 }
                 removing = true;
                 bubblesToTruncate.Add(possibleBubble);
             }
             foreach (var possibleBubble in bubblesToTruncate)
             {
                 db.Remove(possibleBubble);
             }
         }
     }
 }
开发者ID:Xanagandr,项目名称:DisaOpenSource,代码行数:27,代码来源:BubbleQueueManager.cs


示例5: Write

 private static void Write(int operationId,int actionId, string information, string creator,int status)
 {
     string sql = string.Empty;
     StringBuilder sb = new StringBuilder();
     SqlDatabase db = new SqlDatabase(ICJSystem.Instance.ConnectionString1);
     try
     {
         Func.AddSqlString(sb, "INSERT INTO OperationLog");
         Func.AddSqlString(sb, "(");
         Func.AddSqlString(sb, "  [Date],");                
         Func.AddSqlString(sb, "  OperationId,");
         Func.AddSqlString(sb, "  ActionId,");
         Func.AddSqlString(sb, "  Information,");
         Func.AddSqlString(sb, "  [Status],");                
         Func.AddSqlString(sb, "  Creator");
         Func.AddSqlString(sb, ")VALUES");
         Func.AddSqlString(sb, "(");
         Func.AddSqlString(sb, "	'" + DateTime.Now.ToString("yyyyMMddHHmmss") + "',");                
         Func.AddSqlString(sb, "	" + operationId + ",");
         Func.AddSqlString(sb, "	" + actionId + ",");
         Func.AddSqlString(sb, "	'" + information + "',");
         Func.AddSqlString(sb, "	" + status + ",");                
         Func.AddSqlString(sb, "	'" + creator + "'");
         Func.AddSqlString(sb, ")");
         sql = sb.ToString();
         db.ExecuteNonQuery(sql);
     }
     catch (Exception ex)
     {
         ApplicationLog.WriteError(ex);
     }            
 }
开发者ID:tuankyo,项目名称:QLTN,代码行数:32,代码来源:OperationLogger.cs


示例6: DoGet

        protected override void DoGet()
        {
            action = Request["Action"];
            id = Request["id"];
            chkDelFlag.Enabled = DbHelper.isAdmin(Page.User.Identity.Name);

            txtCustomerId.Text = Request["CustomerId"];
            hidId.Value = id;
            hidAction.Value = action;
            txtId.Text = id;
            SqlDatabase db = new SqlDatabase();
            if (action == "Edit")
            {
                lblHeader.Text = "Thông Tin Chi Tiết " + title;
                btnRegister.Text = "Cập Nhật";
                btnCancel.Text = "Đóng";
                btnRegister.CommandName = "Edit";
                txtId.Enabled = false;
                if (!IsPostBack)
                {
                    LoadData();
                }
            }
            else // Add new case
            {
                lblHeader.Text = "Thêm Mới " + title;
                btnRegister.Text = "Thêm Mới";
                btnRegister.CommandName = "Register";
                btnCancel.Text = "Đóng";
            }
        }
开发者ID:tuankyo,项目名称:QLTN,代码行数:31,代码来源:RentContractEdit.aspx.cs


示例7: Load

 public static void Load()
 {
     lock (_lock)
     {
         using (var db = new SqlDatabase<BubbleGroupSettings>(GetPath()))
         {
             var toRemoves = new List<BubbleGroupSettings>();
             foreach (var settings in db.Store.ToList())
             {
                 var bubbleGroup = BubbleGroupManager.Find(settings.Guid);
                 if (bubbleGroup == null)
                 {
                     toRemoves.Add(settings);
                 }
                 else
                 {
                     bubbleGroup.Settings = settings;
                 }
             }
             if (toRemoves.Any())
             {
                 foreach (var toRemove in toRemoves)
                 {
                     db.Remove(toRemove);
                 }
             }
         }
     }
 }
开发者ID:StefanTischler,项目名称:DisaOpenSource,代码行数:29,代码来源:BubbleGroupSettingsManager.cs


示例8: CanGetConnectionWithoutCredentials

 public void CanGetConnectionWithoutCredentials()
 {
     SqlDatabase sqlDatabase = new SqlDatabase();
     sqlDatabase.ConfigurationName = "DbWithSqlServerAuthn";
     sqlDatabase.Initialize(new DatabaseConfigurationView(context));
     Assert.AreEqual("server=localhost;database=northwind;", sqlDatabase.GetConnectionStringWithoutCredentials());
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:7,代码来源:SqlDatabaseFixture.cs


示例9: DoGet

        protected override void DoGet()
        {
            chkDelFlag.Enabled = DbHelper.isAdmin(Page.User.Identity.Name);

            action = Request["Action"];
            id = Request["id"];

            hidId.Value = id;
            hidAction.Value = action;
            hidJobType.Value = Func.ParseString(Request["JobType"]);

            DbHelper.FillList(drpPosition, "Select * from Mst_Position Where Jobtype = '"+ hidJobType.Value +"'", "Position", "id");
            DbHelper.FillListSearch(drpWorkingPlace, "Select WorkingPlaceId + '('+ Name +')' As Name, ID from BD_WorkingPlace Where JobTypeId = '" + hidJobType.Value + "' and BuildingId = '" + Func.ParseString(Session["__BUILDINGID__"]) + "' and DelFlag = 0", "Name", "id");

            SqlDatabase db = new SqlDatabase();
            if (action == "Edit")
            {
                lblHeader.Text = "Thông Tin Chi Tiết " + title;
                btnRegister.Text = "Cập Nhật";
                btnCancel.Text = "Đóng";
                btnRegister.CommandName = "Edit";
                txtStaffId.Enabled = false;
                if (!IsPostBack)
                {
                    LoadData();
                }
            }
            else // Add new case
            {
                lblHeader.Text = "Thêm Mới " + title;
                btnRegister.Text = "Thêm Mới";
                btnRegister.CommandName = "Register";
                btnCancel.Text = "Đóng";
            }
        }
开发者ID:tuankyo,项目名称:QLTN,代码行数:35,代码来源:BD_StaffEdit.aspx.cs


示例10: DoGet

        protected override void DoGet()
        {
            action = Request["Action"];
            id = Request["id"];

            hidId.Value = id;
            hidAction.Value = action;

            SqlDatabase db = new SqlDatabase();
            if (action == "Edit")
            {
                lblHeader.Text = "Thông Tin Chi Tiết " + title;
                btnRegister.Text = "Cập Nhật";
                btnCancel.Text = "Đóng";
                btnRegister.CommandName = "Edit";
                if (!IsPostBack)
                {
                    LoadData();
                }
            }
            else // Add new case
            {
                lblHeader.Text = "Thêm Mới " + title;
                btnRegister.Text = "Thêm Mới";
                btnRegister.CommandName = "Register";
                btnCancel.Text = "Đóng";
            }
        }
开发者ID:tuankyo,项目名称:QLTN,代码行数:28,代码来源:VehicleTypeEdit.aspx.cs


示例11: InsertDefaultIfNull

 private static void InsertDefaultIfNull(BubbleGroup group)
 {
     lock (_lock)
     {
         if (group.Settings == null)
         {
             using (var db = new SqlDatabase<BubbleGroupSettings>(GetPath()))
             {
                 var settings = new BubbleGroupSettings
                 {
                     Mute = false,
                     Unread = true,
                     Guid = group.ID,
                     LastUnreadSetTime = 0,
                     ReadTimes = null,
                     ParticipantNicknames = null,
                     NotificationLed = DefaultNotificationLedColor,
                     VibrateOption = null,
                     VibrateOptionCustomPattern = null,
                     Ringtone = null,
                 };
                 db.Add(settings);
                 group.Settings = settings;
             }
         }
     }
 }        
开发者ID:StefanTischler,项目名称:DisaOpenSource,代码行数:27,代码来源:BubbleGroupSettingsManager.cs


示例12: DoGet

        protected override void DoGet()
        {
            chkDelFlag.Enabled = DbHelper.isAdmin(Page.User.Identity.Name);

            DbHelper.FillList(drpJobType, "Select * from Mst_JobType", "Name", "id");
            action = Request["Action"];
            id = Request["id"];

            hidId.Value = id;
            hidAction.Value = action;

            SqlDatabase db = new SqlDatabase();
            if (action == "Edit")
            {
                lblHeader.Text = "Thông Tin Chi Tiết " + title;
                btnRegister.Text = "Cập Nhật";
                btnCancel.Text = "Đóng";
                btnRegister.CommandName = "Edit";
                if (!IsPostBack)
                {
                    LoadData();
                }
            }
            else // Add new case
            {
                lblHeader.Text = "Thêm Mới " + title;
                btnRegister.Text = "Thêm Mới";
                btnRegister.CommandName = "Register";
                btnCancel.Text = "Đóng";
            }
        }
开发者ID:tuankyo,项目名称:QLTN,代码行数:31,代码来源:BD_WorkingHourEdit.aspx.cs


示例13: CanGetConnectionForStringWithNoCredentials

        public void CanGetConnectionForStringWithNoCredentials()
        {
            DatabaseSyntheticConfigSettings settings = new DatabaseSyntheticConfigSettings(TestConfigurationSource.CreateConfigurationSource());
            ConnectionStringSettings data = settings.GetConnectionStringSettings("NewDatabase");
            SqlDatabase sqlDatabase = new SqlDatabase(data.ConnectionString);

            Assert.AreEqual(@"server=(localdb)\v11.0;database=northwind;integrated security=true;", sqlDatabase.ConnectionStringWithoutCredentials);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:8,代码来源:SqlDatabaseFixture.cs


示例14: CanGetConnectionWithoutCredentials

        public void CanGetConnectionWithoutCredentials()
        {
            DatabaseSyntheticConfigSettings settings = new DatabaseSyntheticConfigSettings(TestConfigurationSource.CreateConfigurationSource());
            ConnectionStringSettings data = settings.GetConnectionStringSettings("DbWithSqlServerAuthn");
            SqlDatabase sqlDatabase = new SqlDatabase(data.ConnectionString);

            Assert.AreEqual(@"server=(localdb)\v11.0;database=northwind;", sqlDatabase.ConnectionStringWithoutCredentials);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:8,代码来源:SqlDatabaseFixture.cs


示例15: CanGetConnectionForStringWithNoCredentials

        public void CanGetConnectionForStringWithNoCredentials()
        {
            SqlDatabase sqlDatabase = new SqlDatabase();
            sqlDatabase.ConfigurationName = "NewDatabase";
            sqlDatabase.Initialize(new DatabaseConfigurationView(context));

            Assert.AreEqual("server=localhost;database=northwind;integrated security=true;", sqlDatabase.GetConnectionStringWithoutCredentials());
        }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:8,代码来源:SqlDatabaseFixture.cs


示例16: CanGetConnectionWithoutCredentials

        public void CanGetConnectionWithoutCredentials()
        {
            DatabaseConfigurationView view = new DatabaseConfigurationView(TestConfigurationSource.CreateConfigurationSource());
            ConnectionStringSettings data = view.GetConnectionStringSettings("DbWithSqlServerAuthn");
            SqlDatabase sqlDatabase = new SqlDatabase(data.ConnectionString);

            Assert.AreEqual(@"server=(local)\sqlexpress;database=northwind;", sqlDatabase.ConnectionStringWithoutCredentials);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:8,代码来源:SqlDatabaseFixture.cs


示例17: CanGetConnectionForStringWithNoCredentials

        public void CanGetConnectionForStringWithNoCredentials()
        {
            DatabaseConfigurationView view = new DatabaseConfigurationView(TestConfigurationSource.CreateConfigurationSource());
            ConnectionStringSettings data = view.GetConnectionStringSettings("NewDatabase");
            SqlDatabase sqlDatabase = new SqlDatabase(data.ConnectionString);

            Assert.AreEqual(@"server=(local)\sqlexpress;database=northwind;integrated security=true;", sqlDatabase.ConnectionStringWithoutCredentials);
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:8,代码来源:SqlDatabaseFixture.cs


示例18: CTor_ConnectionInfoWithDbName_ExtractsCorrectDbName

        public void CTor_ConnectionInfoWithDbName_ExtractsCorrectDbName()
        {
            var cnInfo = new SisoConnectionInfo(
                @"sisodb:provider=Sql2008||plain:Data Source=.\sqlexpress;Initial Catalog=DummyDb;Integrated Security=True");

            var db = new SqlDatabase(cnInfo);

            Assert.AreEqual("DummyDb", db.Name);
        }
开发者ID:darrencauthon,项目名称:SisoDb-Provider,代码行数:9,代码来源:SqlDatabaseTests.cs


示例19: CTor_ConnectionInfoWithDbName_ServerConnectionInfoGainsNoDbName

        public void CTor_ConnectionInfoWithDbName_ServerConnectionInfoGainsNoDbName()
        {
            var cnInfo = new SisoConnectionInfo(
                @"sisodb:provider=Sql2008||plain:Data Source=.\sqlexpress;Initial Catalog=DummyDb;Integrated Security=True");

            var db = new SqlDatabase(cnInfo);

            Assert.AreEqual(@"Data Source=.\sqlexpress;Initial Catalog=;Integrated Security=True", db.ServerConnectionInfo.ConnectionString.PlainString);
        }
开发者ID:darrencauthon,项目名称:SisoDb-Provider,代码行数:9,代码来源:SqlDatabaseTests.cs


示例20: InitializeExisting_WhenDatabaseDoesNotExist_ThrowsSisoDbException

        public void InitializeExisting_WhenDatabaseDoesNotExist_ThrowsSisoDbException()
        {
            DbHelper.DropDatabase(LocalConstants.TempDbName);
            var connectionInfo = new SisoConnectionInfo(LocalConstants.ConnectionStringNameForTemp);

            var db = new SqlDatabase(connectionInfo);

            Assert.Throws<SisoDbException>(() => db.InitializeExisting());
        }
开发者ID:darrencauthon,项目名称:SisoDb-Provider,代码行数:9,代码来源:SqlDatabaseTests.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# SqlDbType类代码示例发布时间:2022-05-24
下一篇:
C# SqlDataType类代码示例发布时间: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