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

  • Thread starter Thread starter Tea
  • Start date Start date
T

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
 
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.CloseConnection);
while(Reader.Read())
for(int x=0; x= Reader.VisibleFieldCount ;x
++)

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top