http://filehelpers.sourceforge.net/example_sqlstorage_extract.html
The example above connects to SQl server.
My requirement is to connect to Oracle DB.I found no class in filehelpers which i can use to connect to oracle DB. Please help if you have any ideas. Thanks a lot.
You can use the GenericDatabaseStorage<T>
class which takes any ADO.NET IDBConnection
type. The following is an example from the FileHelpers source.
[TestClass]
public class GenericDatabaseStorageTests
{
[TestMethod]
public void CurrencyOracleExtractToFile( )
{
GenericDatabaseStorage<OracleConnection, OracleCommand> storage =
new GenericDatabaseStorage<OracleConnection, OracleCommand>(
typeof(TestRecord),
"User Id=SHELL;Password=shell;Data Source=ora9dev"
);
storage.SelectSql = "SELECT * FROM CURRENCY";
storage.FillRecordCallback = new FillRecordHandler( FillRecordOrder );
FileDataLink.EasyExtractToFile( storage, "tempord.txt" );
FileDataLink link = new FileDataLink( storage );
link.ExtractToFile( "tempord.txt" );
TestRecord[] res = (TestRecord[])CommonEngine.ReadFile(typeof(TestRecord), "tempord.txt");
if ( File.Exists( "tempord.txt" ) )
File.Delete( "tempord.txt" );
Assert.AreEqual( 3, res.Length );
Assert.AreEqual( "AED", res[ 0 ].CurrencyCode );
Assert.AreEqual( "AFA", res[ 1 ].CurrencyCode );
Assert.AreEqual( "ALL", res[ 2 ].CurrencyCode );
}
public void FillRecordOrder( object rec, object[ ] fields )
{
TestRecord record = ( TestRecord )rec;
record.CurrencyCode = ( string )fields[ 0 ];
record.Name = ( string )fields[ 1 ];
}
}