-3
有人可以演示如何將字典的值保存到MySQL數據庫中嗎?如何在MySQL數據庫中存儲字典?
public void Update()
{
Dictionary<string,int> t = new Dictionary<string,int>();
for(int i = 0; i < t.Count;i++)
{
//What comes Here?
}
}
有人可以演示如何將字典的值保存到MySQL數據庫中嗎?如何在MySQL數據庫中存儲字典?
public void Update()
{
Dictionary<string,int> t = new Dictionary<string,int>();
for(int i = 0; i < t.Count;i++)
{
//What comes Here?
}
}
首先解決您的迭代循環,第二它是由你來決定,例如:
MySqlConnection conDataBase = new MySqlConnection(constring);
conDataBase.Open();
foreach (KeyValuePair<string, string> entry in)
{
string constring = "..........";
string Query = "insert into Tablename values(@par1,@par2)";
MySqlCommand cmd = new MySqlCommand(Query, conDataBase);
cmd.Parameters.AddWithValue("@par1",entry.Key)
cmd.Parameters.AddWithValue("@par2",entry.Value)
//Execute command
cmd.ExecuteNonQuery();
}