I am developing an app where I have to get value from two tables. I use a Full Text as I am new to it but cannot get value for all the data. I use the code below, but it only returns the first few rows in the column. I need to get value for all data. I hope someone can help me with this.
foreach (DataGridViewRow dr in dgvOperation.Rows)
{
for (int i = 0; i < dgvOperation.Rows.Count; i++)
{
string fullText = dgvOperation.Rows[i].Cells[2].Value.ToString();
var query=@"SELECT DISTINCT Bilag, Dato, Tekst, Konto, Modkonto, Debet, Kredit
FROM (SELECT DISTINCT OpgaveDetail.Id AS Bilag, OpgaveDetail.Dato, OpgaveDetail.Tekst, OpgaveDetail.Modkonto,
(CASE WHEN OpgaveDetail.Beløb < 0 THEN OpgaveDetail.Beløb END) * -1 AS Debet,
(CASE WHEN OpgaveDetail.Beløb > 0 THEN OpgaveDetail.Beløb END) AS Kredit
FROM OpgaveDetail
WHERE KlientId = (SELECT Id
FROM Klient WHERE Navn = 'Benny')
AND FREETEXT(Tekst, '" + fullText + "')
) a
CROSS JOIN (SELECT kn.Konto, kn.Navn
FROM Kontering kn INNER JOIN Kontoplan kp ON kn.Konto = kp.Kontonummer
WHERE kp.LockKonto = 'Unlocked'
AND kn.KlientId = (SELECT Id
FROM Klient WHERE Navn = 'Benny')
AND FREETEXT(kn.Navn, '" + fullText + "')) b";
SqlDataAdapter sda = new SqlDataAdapter(, con);
DataTable dt = new DataTable();
sda.Fill(dt);
dgvOperation.DataSource = dt;
}
}
I am developing an app where I have to get value from two tables. I use a Full Text as I am new to it but cannot get value for all the data. I use the code below, but it only returns the first few rows in the column. I need to get value for all data. I hope someone can help me with this.
foreach (DataGridViewRow dr in dgvOperation.Rows)
{
for (int i = 0; i < dgvOperation.Rows.Count; i++)
{
string fullText = dgvOperation.Rows[i].Cells[2].Value.ToString();
var query=@"SELECT DISTINCT Bilag, Dato, Tekst, Konto, Modkonto, Debet, Kredit
FROM (SELECT DISTINCT OpgaveDetail.Id AS Bilag, OpgaveDetail.Dato, OpgaveDetail.Tekst, OpgaveDetail.Modkonto,
(CASE WHEN OpgaveDetail.Beløb < 0 THEN OpgaveDetail.Beløb END) * -1 AS Debet,
(CASE WHEN OpgaveDetail.Beløb > 0 THEN OpgaveDetail.Beløb END) AS Kredit
FROM OpgaveDetail
WHERE KlientId = (SELECT Id
FROM Klient WHERE Navn = 'Benny')
AND FREETEXT(Tekst, '" + fullText + "')
) a
CROSS JOIN (SELECT kn.Konto, kn.Navn
FROM Kontering kn INNER JOIN Kontoplan kp ON kn.Konto = kp.Kontonummer
WHERE kp.LockKonto = 'Unlocked'
AND kn.KlientId = (SELECT Id
FROM Klient WHERE Navn = 'Benny')
AND FREETEXT(kn.Navn, '" + fullText + "')) b";
SqlDataAdapter sda = new SqlDataAdapter(, con);
DataTable dt = new DataTable();
sda.Fill(dt);
dgvOperation.DataSource = dt;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.