本文整理汇总了C#中DatabaseHelper.CloseDatabase方法的典型用法代码示例。如果您正苦于以下问题:C# DatabaseHelper.CloseDatabase方法的具体用法?C# DatabaseHelper.CloseDatabase怎么用?C# DatabaseHelper.CloseDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseHelper
的用法示例。
在下文中一共展示了DatabaseHelper.CloseDatabase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btn_Connect_Click
private void btn_Connect_Click(object sender, EventArgs e)
{
// @"data source=KHIEM-PC\SQLEXPRESS" + ";initial catalog=QLKhoDienLuc" + ";persist security info=True;user id=sa" + ";password=2051990" + ";MultipleActiveResultSets=True;";
StringBuilder Con = new StringBuilder("Data Source=");
Con.Append(txtServerName.Text);
Con.Append(";Initial Catalog=");
Con.Append(txtTenCSDL.Text);
if (String.IsNullOrEmpty(txtUser.Text) && String.IsNullOrEmpty(txtPwd.Text))
Con.Append(";Integrated Security=true;");
else
{
Con.Append(";persist security info=True");
Con.Append(";User Id=");
Con.Append(txtUser.Text);
Con.Append(";Password=");
Con.Append(txtPwd.Text);
Con.Append(";MultipleActiveResultSets=True;");
}
string strCon = Con.ToString();
DatabaseHelper help = new DatabaseHelper();
if (help.CheckConnection(strCon) == 0)
{
MessageBox.Show("Kết nối thất bại vui lòng kiểm tra lại thông tin ");
return;
}
else
{
Utilities.clsThamSoUtilities.connectionString = strCon;
help.CloseDatabase();
updateConfigFile(strCon);
this.Close();
}
}
示例2: DocFileCauHinh
private void DocFileCauHinh()
{
try
{
XmlDocument XmlDoc = new XmlDocument();
//Loading the Config file
XmlDoc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
// XmlDoc.Load("App.config");
foreach (XmlElement xElement in XmlDoc.DocumentElement)
{
if (xElement.Name == "connectionStrings")
{
//setting the coonection string
var temp = xElement.LastChild.Attributes[1].Value;
try
{
DatabaseHelper help = new DatabaseHelper();
if (help.CheckConnection((string)temp) == 0)
{
frmKetNoi frm = new frmKetNoi();
frm.MdiParent = this;
// Display the new form.
frm.Show();
}
else
{
Utilities.clsThamSoUtilities.connectionString = temp;
help.CloseDatabase();
}//
}
catch (Exception ex)
{
}
}
if (xElement.Name == "appSettings")
{
bool temp = bool.Parse(xElement.ChildNodes.Item(0).Attributes[1].Value);
if (temp == true)
{
frmDangNhap frm = new frmDangNhap();
frm.MdiParent = this;
// Display the new form.
frm.Show();
return;
}
Utilities.clsThamSoUtilities.isSectionLogin = true;
}
}
//writing the connection string in config file
// XmlDoc.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
//clsThamSoUtilities.ID_Kho = int.Parse(config.AppSettings.Settings["IDkho"].Value.ToString());
}
catch (Exception ex)
{
// MessageBox.Show("Chưa cấu hình CSDL! Vui lòng cấu hình hệ thống trước.");
}
}