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());
}
}