我有这个代码:
private void GenerarTicket(int prmFOLIO)
{
try
{
string Ticket = "Nombre de la tienda: UAMCAV\n" +
"RFC:XXXXXX\n" +
"------------------------------\n" +
"ARTICULO CANT PRECIO TOTAL\n" +
"------------------------------\n";
string varSQL = "SELECT Detalle_Ventas.folio, Detalle_Ventas.id_articulo, Detalle_Ventas.cantidad, Detalle_Ventas.p_unitario, Detalle_Ventas.iva*Detalle_Ventas.p_unitario AS iva, Detalle_Ventas.cantidad*Detalle_Ventas.p_unitario AS total, articulos.desc_producto, Ventas.user_login, LEFT(Ventas.fecha,10) AS fecha " + " FROM Ventas INNER JOIN (articulos INNER JOIN Detalle_Ventas ON articulos.id_articulo=Detalle_Ventas.id_articulo) ON Ventas.folio=Detalle_Ventas.folio WHERE Ventas.folio=" + prmFOLIO + "";
string DetalleTicket = "";
double varGranTotal = 0;
OleDbConnection cnnTicket =new OleDbConnection(Clases.clsMain.CnnStr);
cnnTicket.Open();
OleDbCommand cmdTicket =new OleDbCommand(varSQL, cnnTicket);
OleDbDataReader drTicket;
**drTicket = cmdTicket.ExecuteReader();**
while (drTicket.Read())
{
DetalleTicket +=
drTicket["desc_producto"].ToString() + " " +
drTicket["cantidad"].ToString() + " " +
String.Format("{0:C}",
drTicket["p_unitario"]) + " " +
String.Format("{0:C}",
drTicket["total"]) + "\n";
varGranTotal += (double)drTicket["total"];
}
DetalleTicket +=
"------------------------------\n" +
"TOTAL: " + String.Format("{0:C}",
varGranTotal);
Ticket += DetalleTicket;
mPrintDocument _mPrintDocument = new mPrintDocument(Ticket);
_mPrintDocument.PrintPreview();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
我多次修改了粗体部分,因为总是给我抛出一个奇怪的异常,比如别名“desc_producto”中的循环引用,我使用我创建的.dll来生成购物票,但是没有办法修复这个例外!你能帮助我吗?顺便说一句,这是数据库中项目的名称。