I have developed an app in Visual Studio in my company. Everything works well (with many difficulties for me) but now I'm not able to solve a problem and I haven't found a solution on the web. So I need your help.
I have a database with one table in which I store different data (I summarize here):
ID of line (st_ID)
code (st_ID_Prova)
Type of test (st_tipo_prova)
many values
What I have done and work well with Table adapter wizard in Dataset manager is to filter my data by 'st_ID_Prova' and 'st_tipo_prova'
SELECT
st_ID, st_ID_Prova, st_termica1, st_termica2, st_termica3, st_termica4,
st_termica5, st_termica6, st_termica7, st_termica8, st_termica9,
st_termica10, st_delta, st_commento, st_f_switch, st_KLIXON, st_ora,
st_gradiente1, st_gradiente10, st_gradiente2, st_gradiente3,
st_gradiente4, st_gradiente5, st_gradiente6, st_gradiente7,
st_gradiente8, st_gradiente9, st_tipo_prova, st_termica11,
st_gradiente11, st_termica12, st_gradiente12, st_termica13,
st_gradiente13, st_termica14, st_gradiente14, st_termica15,
st_gradiente15, st_termica16, st_gradiente16
FROM
st_termiche
WHERE
(st_ID_Prova LIKE @ID_PROVA) AND (st_tipo_prova LIKE @test_type)
ORDER BY
st_ID
Each 'st_ID_Prova' contains many 'st_tipo_prova' and I want to display data of more than one 'st_tipo_prova' for only one 'st_ID_Prova'
For example
st_ID_Prova = 3
contains
st_tipo_prova = A
st_tipo_prova = B
st_tipo_prova = C
One line ST_ID, ST_ID_PROVA, st_tipo_prova, ...many values
1,3,A,.....
2,3,A,.....
3,3,B,.....
4,3,C,.....
4,3,C,.....
4,3,C,....
I have tried to pass parameter using
variabile_tipo_prova="A or B or C"
Me.St_termicheTableAdapter.Fill(Me.Dati_vari_dataset.st_termiche, "" & st_grafico_ID_PROVAToolStripTextBox.Text & "", "" & variabile_tipo_prova)**
but it is not correct. The correct way is:
(st_tipo_prova LIKE A) or (st_tipo_prova LIKE B) or (st_tipo_prova LIKE C)
But I cannot do that.
I have tried with SQL IN
, very good for me
SELECT
st_ID, st_ID_Prova,
--- all those many many other columns
FROM
st_termiche
WHERE
(st_ID_Prova LIKE @ID_PROVA)
AND (st_tipo_prova IN (@test_type))
ORDER BY
st_ID
I have tried to pass parameter
variabile_tipo_prova="'A', 'B', 'C'"
Me.St_termicheTableAdapter.Fill(Me.Dati_vari_dataset.st_termiche, "" & st_grafico_ID_PROVAToolStripTextBox.Text & "", "" & variabile_tipo_prova)
but this doesn't work.
But if I change the select string in the dataset in this way
SELECT
st_ID, st_ID_Prova,
--- all those many many other columns
FROM
st_termiche
WHERE
(st_ID_Prova LIKE @ID_PROVA)
AND (st_tipo_prova IN ('A','B','C'))
ORDER BY
st_ID
IT RUNS
WHY? How can I pass the parameter @test_type to obtain the same result? How can I display the select command during debug to understand what happened.
Thanks to everyone.