本文整理汇总了C#中SqlDatabase类的典型用法代码示例。如果您正苦于以下问题:C# SqlDatabase类的具体用法?C# SqlDatabase怎么用?C# SqlDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SqlDatabase类属于命名空间,在下文中一共展示了SqlDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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";
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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";
}
}
示例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);
}
}
}
}
}
示例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());
}
示例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";
}
}
示例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";
}
}
示例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;
}
}
}
}
示例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";
}
}
示例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);
}
示例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);
}
示例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());
}