Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • Administrators
Posted

Does either version work if you simplify the parameters?

i.e. instead of

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"); 

try

this.qryALL1TableAdapter.FillByClienteDataTipo(this.sascrDataSet.qryALL1, cbCliente.Text, System.DateTime.Parse(DataIni.Text), System.DateTime.Parse(DataFin.Text), "Boletim"); 

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

Hi dear Portuguese friend,

 

As this is a forum, and here you discuss things, we suggest ideas, and we take out dought sharing the knowlegde and the experience of each one, I wanna suggest that using accented word as (à,é,ç,etc...)as fields names its not very good idea and you can get some incompatibilities with it.

And i wanna also sugest that using ODBC connection even its more standard and easy to use, it is slowest that OLEDB connection. And it is one more "tier" you are using in your application, who knows you related problem is related with the accent word you use as table fields in you ODBC connection.

 

.eof

 

Teixeira

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...