0
I have a DataGridView
and by clicking on that DataGridView
I have to write a file select
comparing one column of a table to another column of another table and what results from that select
is what I have to write in the file.
This is how I am writing in the file right now but it is not well done as it is writing what it shows in DataGridView
.
if (dataGridViewEnviarDados.SelectedRows.Count > 0)
{
foreach (DataGridViewRow r in dataGridViewEnviarDados.SelectedRows)
{
var transactionHandler = new TransactionHandler();
FileInfo arquivo = new FileInfo("C:\\Users\\HP8200\\Desktop\\faturas\\"
+ r.Cells[0].Value.ToString()
+ r.Cells[1].Value.ToString()
+ r.Cells[2].Value.ToString() + ".txt");
using (TextWriter tw = new StreamWriter(arquivo.FullName,false,Encoding.Default))
{
foreach (DataGridViewColumn c in dataGridViewEnviarDados.Columns)
{
tw.Write(r.Cells[c.Name].Value.ToString() +";");
}
}
}
}
And the select I’m using is this :
SELECT X.[TransDocument], X.[TransSerial],X.[TransDocNumber], I.[CreateDate], I.[PartyFederalTaxID], I.[TotalAmount],
I.[ShipToAddressDetailLine1], I.[ShipToPostalCode], U.[ItemID], U.[TotalGrossAmount], U.[TotalNetPrintAmout], U.[Quantity], Y.[ItemID], Y.[BarCode], Y.[TaxableGroupID]
FROM
[ELISAData].[dbo].[SaleTransaction] I
INNER JOIN [ELISAData].[dbo].[SaleTransactionDetails] U
ON I.[TransDocNumber] = U.[TransDocNumber]
INNER JOIN [ELISAData].[dbo].[UXMenu] X
ON U.[TransDocNumber] = X.[TransDocNumber]
INNER JOIN [ELISAData].[dbo].[Item] Y
ON U.[ItemID] = Y.[ItemID]
WHERE
I.[TransDocNumber] = U.[TransDocNumber] AND
X.[TransDocNumber] = U.[TransDocNumber] AND
U.[ItemID] = Y.[ItemID]
Order by [TransDocNumber]
It’s hard to understand what you need to do!
– novic
I’ll try to explain myself better, I need to make a file . txt , the contents of the file must be the select of the comparison of two tables
– Pedro Azevedo
@Rovannlinhalis did not understand what you need sorry
– Pedro Azevedo
exactly how the datagridview has to be displayed, structure of your tables and the selects you have to run
– Rovann Linhalis
@Rovannlinhalis already updated
– Pedro Azevedo
the select, before there were 2, already joined with the Inner Join as it had commented ?
– Rovann Linhalis
@Rovannlinhalis because I wanted to facilitate the way to explain makes with only two tables I try to adapt, only I put this select because you asked to by select what I use
– Pedro Azevedo
Let’s go continue this discussion in chat.
– Pedro Azevedo