用户信息和数据库的增删改查修改
This commit is contained in:
1 parent
10611241d1
commit
5d9ab90ed3
16 files changed
+511
-23
No files matched your search
@@ -18,7 +18,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
private string DB_IP = null!;
|
||||
private string DB_PASSWORD = null!;
|
||||
|
||||
public void Config(string ip, string name, string type, string id, string password)
|
||||
public async void Config(string ip, string name, string type, string id, string password)
|
||||
{
|
||||
DB_IP = ip;
|
||||
DB_ID = id;
|
||||
@@ -26,7 +26,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
DB_TYPE = type;
|
||||
DB_PASSWORD = password;
|
||||
|
||||
_= ConfigAsync();
|
||||
await ConfigAsync();
|
||||
|
||||
}
|
||||
public async Task ConfigAsync()
|
||||
@@ -63,6 +63,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex);
|
||||
Console.WriteLine("DataBase Link timeout\n"+ex.ToString());
|
||||
// 失败处理
|
||||
return; // 直接返回,不执行后续代码
|
||||
@@ -76,7 +77,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
// 创建一个空的 DataTable 用于存放查询结果
|
||||
DataTable dataTable = new DataTable();
|
||||
|
||||
// 沿用你原有的数据库连接字符串构建逻辑
|
||||
// 数据库连接字符串构建逻辑
|
||||
var builder = new SqlConnectionStringBuilder
|
||||
{
|
||||
DataSource = DB_IP,
|
||||
@@ -109,8 +110,9 @@ namespace SunlightAggregationManager.UserClass
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex);
|
||||
Console.WriteLine("DataBase Query failed\n" + ex.ToString());
|
||||
// 这里可以选择将异常抛出给调用方,或者返回一个空的 DataTable
|
||||
// 将异常抛出给调用方,或者返回一个空的 DataTable
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user