DeviceManager/Intend/EntityToMssql.cs

49 lines
1.3 KiB
C#
Raw Normal View History

2024-05-28 14:36:38 +00:00
using DevExpress.XtraEditors;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace Intend
{
public partial class EntityToMssql : XtraForm
{
public EntityToMssql()
{
InitializeComponent();
}
private void simpleButton1_Click(object sender, EventArgs e)
{
Ver1_1();
}
void Ver1_1()
{
try
{
using (SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = "Data Source=www.clovejunti.cn,11433;Initial Catalog=DriveMaintenance;Persist Security Info=True;User ID=sa;Password=P@ssw0rd;",
DbType = SqlSugar.DbType.SqlServer,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute
}))
{
List<MainModel> lst = db.Queryable<MainModel>().ToList();
memoEdit1.EditValue = JsonConvert.SerializeObject(lst);
}
}
catch (SqlSugarException e)
{
MessageBox.Show(e.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}