gpt4 book ai didi

c# - 我如何将字符串值分配给 List

转载 作者:行者123 更新时间:2023-11-30 22:40:59 25 4
gpt4 key购买 nike

<分区>

我有如下代码

string str=sbr.ToString();

这里我将从 SQLLITE 中的 str 中获取所有表名

foreach (KeyValuePair<string, Dictionary<string, List<string>>> key in tableNames)
// Here i am geting only one n tablenames so i would like to assign str values to tableNames so that it will search for all if my != condition fails

{
if (str.Contains(key.Key))
{
if (key.Key != "DBVERSION")
{
bool verify = false;
if(DBUpdate(tableNames, key.Key)==false)
{
GetEndDate(tableNames, key.Key);
}
DBInsert(tableNames, key.Key);
}
}
}

我想将 str 值分配给 tablename 字段,我想与 key 值进行比较谁能帮我?

        public bool Update(Dictionary<string, Dictionary<string, List<string>>> tableNames, SQLiteConnection m_oConn)
{
bool m_bFlag = false;
SQLiteDataAdapter adp=new SQLiteDataAdapter("select tbl_name from sqlite_master where type='table' order by tbl_name",m_oConn);

DataSet ds=new DataSet();
if (m_oConn.State == ConnectionState.Closed)
{
m_oConn.Open();
}
StringBuilder sbr=new StringBuilder();
StringBuilder collumnNames = new StringBuilder();

adp.Fill(ds);

for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
sbr.Append(ds.Tables[0].Rows[i][0].ToString()+",");
}
string str=sbr.ToString();


foreach (KeyValuePair<string, Dictionary<string, List<string>>> key in tableNames)
{

if (str.Contains(key.Key))
{
if (key.Key != "DBVERSION")
{
bool verify = false;
if(DBUpdate(tableNames, key.Key)==false)
{
GetEndDate(tableNames, key.Key);
}
DBInsert(tableNames, key.Key);

}
}
else
{
foreach (KeyValuePair<string, List<string>> ColNameKey in key.Value)
{
string strd = "";

List<string> values = ColNameKey.Value;
if(values[0].Contains("-"))
{
strd="DATE";
}
else if (values[0].Contains("'"))
{
strd = "CHAR";
}
else if (values[0].Contains("."))
{
strd = "FLOAT";
}
else
{
strd = "INT";
}

//GetDataTypes(ColNameKey.Key,out strd);
collumnNames.Append(ColNameKey.Key + " "+strd+",");

}
m_oCmd.CommandText = "create table " + key.Key + "(" + collumnNames.ToString().TrimEnd(',') + ")";
m_oCmd.ExecuteNonQuery();
sw.WriteLine(key.Key+" table created");
DBInsert(tableNames, key.Key);
}


}
//m_oConn.Close();
m_bFlag = true;
return m_bFlag;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com