C# VS 2005 - SQL Query Parameters to an ODBC DataSource

csharp Brazil
  • 15 years ago

    Hello everyone,

    I used to have my MS Access 2002 DataBase placed in my application folder and connect to it through an OLEDB connection. Everything worked fine.

    Now I decided to create an ODBC DataSource and suddenly I'm not able to pass parameters to the SQL Query the way I used to with the OLEDB connection.

    Here's a sample code of the SQL Query and C# code on my form:

    FillByClienteDataNumero query:

    SELECT Data, Cliente, Tipo, Número, Espécie, Lote, Análise, Preço
    FROM qryALL1
    WHERE (Cliente = ?) AND (Data >= ?) AND (Data <= ?) AND (Tipo = ?)
    ORDER BY Data, Número



    Form code:

    private void btnSeekBA_Click(object sender, EventArgs e)
    {
    try
    {
    this.qryALL1TableAdapter.FillByClienteDataTipo(this.sascrDataSet.qryALL1, cbCliente.Text, new System.Nullable<System.DateTime>(((System.DateTime)(System.Convert.ChangeType(DataIni.Text, typeof(System.DateTime))))), new System.Nullable<System.DateTime>(((System.DateTime)(System.Convert.ChangeType(DataFin.Text, typeof(System.DateTime))))), "Boletim");
    }
    catch (System.Exception ex)
    {
    System.Windows.Forms.MessageBox.Show(ex.Message);
    }
    }










    Any ideas why the above SQL query and code work with an OLEDB connection but not with an ODBC DataSource? Thanks a million!

    JC.

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.” - Donald Knuth