gpt4 book ai didi

mysql - MySql 查询和 asp.net c# 之间的结果差异

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

我有一个 MySql 命令,如下所示:

    string listfh = "Select class_id, location_nm, b.ref_desc, c.ref_desc ,a.days From fh_info as a LEFT JOIN (ref_section as b, ref_language as c) ON  ((a.section_id=b.cd) and (a.language_id = c.cd)) WHERE year(a.fh_dt) = '2015' And region_id like 'B%' Order by fh_dt desc";    MySqlDataAdapter daFt = new MySqlDataAdapter(listfh, conn);    daFt.Fill(dtList);

结果返回null。但是当在 Navicat Query 中运行相同的命令时,它会返回正确的答案(2 行)。怎么了?

最佳答案

检查您的 connectionString(conn) 是否正确指向您的数据库,并在您的表/ View 名称之前提及您的数据库名称,以便与数据库对象建立正确的连接,例如:

    string listfh = "Select class_id, location_nm, b.ref_desc, c.ref_desc ,a.days From DatabaseName.dbo.fh_info as a LEFT JOIN (DataBaseName.dbo.ref_section as b, DatabaseName.dbo.ref_language as c) ON  ((a.section_id=b.cd) and (a.language_id = c.cd)) WHERE year(a.fh_dt) = '2015' And region_id like 'B%' Order by fh_dt desc";
MySqlDataAdapter daFt = new MySqlDataAdapter(listfh, conn);
daFt.Fill(dtList);

关于mysql - MySql 查询和 asp.net c# 之间的结果差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35386044/

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