【发布时间】:2020-08-31 16:48:57
【问题描述】:
这是我的类 (getProductItem),用于从 Query 中获取数据并将其设置在 SAP Crystal Report 上:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApp1
{
public class getProductItem
{
public static int nomor = 0;
public int No
{
get
{
return getProductItem.nomor++;
}
}
public string nama_produk { get; set; }
public string harga_satuan { get; set; }
public string jumlah_penjualan { get; set; }
public string total_harga { get; set; }
}
}
这是我的问题,我必须用 .Query 改变什么,我最终遇到了错误。 'MySqlConnection' does not contain a definition for 'Query' and no accesible edtension method 'Query'accepting a first argument of type 'MySqlConnection'could be found (are you missing a using directive or an assembly reference?)
我正在学习使用 SQL 数据库的教程,但我使用的是 mysql 数据库。所以我不知道如何解决它。
顺便说一句,下面的代码来自另一个 windows 窗体,它设置了一个查询来获取数据并将其放在getProductItem 的列表中,但它并不顺利
using (MySqlConnection dbConn = new MySqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString))
{
dbConn.Open();
string insertQuery = "SELECT p.nama_produk, d.harga_satuan, d.jumlah_penjualan, d.total_harga FROM detail_penjualan_produk d JOIN produk p ON p.id_produk = d.id_produk WHERE d.id_penjualan = '" + UCTransaction.IDPenjualan + "' ";
List<getProductItem> list = dbConn.Query<getProductItem>(insertQuery, CommandType: CommandType.Text).ToList();
}
【问题讨论】:
-
你遇到了什么错误?请提供一些具体信息。
-
对不起,现在你又可以在上面看到了,我只是把它放在错误信息中
标签: c# mysql visual-studio