gpt4 book ai didi

jquery - asp.net json将数据从表复制到另一个表

转载 作者:行者123 更新时间:2023-11-29 09:48:18 24 4
gpt4 key购买 nike

我正在尝试将数据从“bareme”表复制到“affiche”表,然后我将从表“affiche”检索数据

    public class db
{
MySqlConnection DefaultConnection = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);


public DataSet enter()
{
MySqlCommand com = new MySqlCommand("INSERT INTO affiche (nivJauge,qte_cons) select * from bareme", DefaultConnection);
MySqlDataAdapter da = new MySqlDataAdapter(com);
DataSet ds = new DataSet();
da.Fill(ds); //the ERROR appears here
return ds;
}

}

database_Access_Layer.db dblayer = new database_Access_Layer.db();
public ActionResult affiche()
{
return View();
}

public JsonResult get_data()
{
DataSet ds = dblayer.enter();
List<jauge> listjauge = new List<jauge>();
foreach (DataRow dr in ds.Tables[0].Rows)
{
listjauge.Add(new jauge
{
nivJauge = Convert.ToDouble(dr["nivJauge"]),
qte_cons = Convert.ToDouble(dr["qte_cons"]),
});
}
return Json(listjauge, JsonRequestBehavior.AllowGet);
}




<script>
$(function () {
$.get("get_data", {}, function (data) {
var row;
$.each(data, function (i, v1) {
row += "<tr><td>" + v1.nivJauge+ "</td><td>" + v1.qte_cons+ "</td></tr>"
});
$("#tbldata").append(row);
})
})
</script>

在调试时,此问题出现在“da.Fill(ds)”行中

错误:MySql.Data.MySqlClient.MySqlException:“‘字段列表’中存在未知列‘qte_cons’”

最佳答案

您好,您的问题是

    INSERT INTO affiche (nivJauge,qte_cons) select * from bareme

使用 select 语句的列名。应该是这样的

    INSERT INTO affiche (nivJauge,qte_cons) select first_column_name, second_column_name from bareme

关于jquery - asp.net json将数据从表复制到另一个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55272277/

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