Hello all,
I have this problem:
I need to get data from a table giving some parameters. The parameter list can be very long, like this:
string SelectStatement = “select unidade, numero, date ” +
“from _dsa_ihs_table ” +
“where unidade in (‘1234’, ‘1235’, ‘1236’, ‘1237’, …, ‘9999’) ” +
“order by unidade” ;
And if i use that code with a big parameter list i receive the following error message: ‘SQL: Statement too long.’ I can use parameters instead. Something like this:
string SParameter = “‘1234’, ‘1235’, ‘1236’, ‘1237’, …, ‘9999’”;
string SSelect = “select unidade, numero, date ” +
“from _dsa_ihs_table ” +
“where unidade in (?) ” +
“order by unidade” ;
OleDbCommand ODCComando = ODCLigacao.CreateCommand();
ODCComando.Parameters.Add(“lista”, OleDbType.LongVarChar);
ODCComando.Parameters[“lista”].Value = SParameter;
ODCComando.CommandText = SSelect;
OleDbDataAdapter ODDAAdaptador = new OleDbDataAdapter();
ODDAAdaptador.SelectCommand = ODCComando;
ODCLigacao.Open();
ODDAAdaptador.Fill(ODSDataset, “cursor_dados”);
ODCLigacao.Close();
This way i got no error, but i get no data also…
There’s something wrong with the syntax? With the parameter string?
Does anyone have the answer?
Thank you,
Joaquim