Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Joining data from a local datatable and a database table
Message
De
19/05/2007 03:15:47
 
 
À
18/05/2007 05:54:28
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01226621
Message ID:
01227012
Vues:
21
Hi,

>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", System.Data.OleDb.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?

You'd need to pass the parameters in seperately:
"where unidade in (?,?,?,?, etc) " +"
which isn't particularly practical. Maybe pass the SParameter to a SP instead?
Regards,
Viv
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform