Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# VS 2005 - SQL Query Parameters to an ODBC DataSource

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

Scheduled Pinned Locked Moved C#
databasecsharpvisual-studioquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JC Carmo
    wrote on last edited by
    #1

    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.Convert.ChangeType(DataIni.Text, typeof(System.DateTime))))), new System.Nullable(((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.

    G 1 Reply Last reply
    0
    • J JC Carmo

      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.Convert.ChangeType(DataIni.Text, typeof(System.DateTime))))), new System.Nullable(((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.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Standard question #1: What do you mean by "not working"? Standard question #2: What error message do you get? --- b { font-weight: normal; }

      J 1 Reply Last reply
      0
      • G Guffa

        Standard question #1: What do you mean by "not working"? Standard question #2: What error message do you get? --- b { font-weight: normal; }

        J Offline
        J Offline
        JC Carmo
        wrote on last edited by
        #3

        Hi Guffa, I get the following error message: ERROR [HY104][Microsoft][Microsoft Access ODBC Driver]Invalid precision value Thanks for your reply. Bye for now. JC.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups