I have this code:
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);
}
}
I modified the bold section many times because there is always throwing a strange exception for me, like a circular reference in the alias "desc_producto", I use a .dll created by me to generate a shopping ticket, but there is no way to fix this exception! Can you help me? By the way, that's the name of the item in the data base.