473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Query MS Access data 'like ....' from CSharp

Tea


Please help me !
My data in Microsoft Access
Query direct in MS Access : I wrote
Select * from TableA where field1 like '*abc*'
Query from Visual Basic : I wrote
Select * from TableA where field1 like '%abc%'
But query from C#: I don't known how to write!
?????
Please help me !
Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Apr 20 '07 #1
1 2493
On Apr 20, 4:39 am, Tea <t...@devdex.comwrote:
Please help me !
My data in Microsoft Access
Query direct in MS Access : I wrote
Select * from TableA where field1 like '*abc*'
Query from Visual Basic : I wrote
Select * from TableA where field1 like '%abc%'
But query from C#: I don't known how to write!
?????
Please help me !
Thanks

*** Sent via Developersdexhttp://www.developersdex.com***
using System.Data;
using System.Data.Common;
class data
{
void test()
{

DbProviderFactory Factory =
DbProviderFactories.GetFactory("System.Data.OleDb" );
DbConnection Connection =
Factory.CreateConnection();
Connection.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"C:\Bill Main
\Development\Office 97\Interactive Suite CDN 4.2\Data Only 4.1 Plus
Runtime.mdb\"";
DbCommand Command=Connection.CreateCommand();
Command.CommandText="Select * from TableA
where field1 like '*abc*'";
Command.CommandType=CommandType.Text;
DbDataReader
Reader=Command.ExecuteReader(CommandBehavior.Close Connection);
while(Reader.Read())
for(int x=0; x= Reader.VisibleFieldCount ;x
++)

Console.WriteLine(Reader.GetValue(x).ToString());
}
}

Apr 22 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
2
by: Mattyboy | last post by:
Guys I have built a database with saved queries that runs fine in Access but when I call it from the web using ASP, an exception occurs. I have tried multiple ways of testing the databases with...
12
by: Joe Stanton | last post by:
Hello Group I have a query that works in Oracle and SQL Server, but fails in Microsoft Access. The query is: SELECT data fromTABLE1 WHERE data>='A&' AND data<'A''' Here is my sample data:
15
by: C# Learner | last post by:
Hi, I have a string (System.String) which holds some data. This data is encoding in UTF8 (i.e. anywhere in the string where there should be a single 'é' character, there will be two characters...
8
by: VM | last post by:
If I want to run this query ( " col_output like '<del> *BOX' " ), it'll throw an exception. How can I search for any rows that begin with '<del>' and end with 'BOX'? Would it also be possible to...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
1
by: Dennis Kuntzemann | last post by:
Hello, I am trying to get access to an MySql-Server over CSharp. As I am not sure whether it is an csharp or sql driver problem, i am posting it here. I got the following error: PM...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
5
by: wugon.net | last post by:
question: db2 LUW V8 UNION ALL with table function month() have bad query performance Env: db2 LUW V8 + FP14 Problem : We have history data from 2005/01/01 ~ 2007/05/xx in single big...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.