Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

This must be a very simple problem but I am unable to solve it.
I have written an ms access query within C#.net project to retrieve rows.
Even though there are no errors, rows are not getting retrieved.
Here is my code:

C#
OleDbConnection xsconn = new OleDbConnection();
xsconn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0; Data source=D:\\mail.accdb";
 xsconn.Open();

string qto = "SELECT [NAMES] FROM " + var_name + " WHERE [STATUS]='to'";

                OleDbDataAdapter da = new OleDbDataAdapter(qto, xsconn);
                DataSet ds = new DataSet();
                da.Fill(ds);


I have done the same exercise in VB.net many a times fluently & successfully..so this is kind of disappointment to me..!!

What I have tried:

I have copied my code in question.
Since there are no errors, I am clueless how to solve it.
Posted
Updated 31-Mar-16 0:49am
Comments
F-ES Sitecore 31-Mar-16 5:26am    
Use the debugger to see what the "qto" variable contains and copy its contents to the clipboard. Open the database via Access, create a new query and paste the sql into it and run it. Does the sql look right? Does Access accept it as valid? Does it return results when you execute it?

Also if var_name has come from user input you'll need to think about the possibilities of SQL injection attacks.
Karthik_Mahalingam 31-Mar-16 5:29am    
remove the filter WHERE [STATUS]='to' and try.
might be filter has no records.
planetz 31-Mar-16 5:48am    
hi Karthik...I took up your suggestion of running query removing filter... surprisingly the data is wrapped in <div> tags..!! Like this

<div>abc@xyz.com</div>
Karthik_Mahalingam 31-Mar-16 5:50am    
all the rows?
planetz 31-Mar-16 5:51am    
all the rows and all the columns

1 solution

Problem solved.

Why does my text box have &lt;div&gt; ...... &lt;div&gt; tags?[^]

This is the link that helped me. I am using MS Access 2013. Initially I chose long text for data format. When I change it to short text, there was no more div tags around data.

Feeling relieved..!!
Thank you..!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900