Data Access Application Block with C#


G

Guest

Hi,

I have Microsoft Enterprise Library 2005 installed on my local system. I'm
developing in C# using Visual Studio 2003 IDE with framework 1.1.

I am automating a process that will use a DLL assembly I am developing. I
am going to use the data Access Application Block for data access in my DLL
assembly, and a Windows Service will execute the DLL on a set schedule. To
make this happen I will add the Common, Configuration, and Data projects to
my DLL assembly project.

My question is, how would I handle the SQL Server and Jet OLEDB database
Instances? The reason for Jet OLEDB, is my process will open an Excel
spreadsheet, read the data, then insert that data into a SQL Server database
table. However, I am fairly new to the Microsoft Enterprise Library 2005,
and it appears that Microsoft only provided SQL Server and Oracle access with
this reusable code.

Just an FYI, I keep my question short for simplicity, but there is more
going on in my DLL assembly that pushing data to SQL Server otherwise I would
have used DTS.

Thanks,
 
Ad

Advertisements

G

Guest

Thanks. It does work in Visual Studio 2003 just fine.

For those interested in this, here's some additional important info from the
original author:
(http://www.geekswithblogs.net/cbreisch/archive/2005/05/03/38945.aspx)

Also, to make it work with Visual Studio 2003:

1. Create a new folder called OLEDB in C:\Program Files\Microsoft
Enterprise Library June 2005\src\Data\

2. Extract the contents from the download at gotdotnet link

3. Find the folder called Tests, and copy the entire Tests folder to the
OLEDB folder you created

4. Do the same for the files called OleDbCommandWrapper.cs & and
OleDbDatabase.cs

Just include it with you Data project so the next time you add the Data
project to your project you will have it.

Thanks again sloan.
 
Ad

Advertisements

S

sloan

And here is the list of connection strings. (dataConfiguration.config file)
for Excel , Access, and TextFile:



<instances>


<instance name="pubsAccessInstance" type="OleDB"
connectionString="pubsAccessConnectionString" />

<instance name="pubsExcelInstance" type="OleDB"
connectionString="pubsExcelConnectionString" />

<instance name="textFileInstance" type="OleDB"
connectionString="textFileConnectionString" />


</instances>
<connectionStrings>



<connectionString name="pubsAccessConnectionString">
<parameters>
<parameter name="Provider" value="Microsoft.Jet.OLEDB.4.0"
isSensitive="false" />
<parameter name="Data Source"
value="c:\AccessDatabaseCopy\pubs2000.mdb" isSensitive="true" />
</parameters>
</connectionString>

<connectionString name="pubsExcelConnectionString">
<parameters>
<parameter name="Provider" value="Microsoft.Jet.OLEDB.4.0"
isSensitive="false" />
<parameter name="Data Source" value="C:\ExcelPubsCopy\pubs.xls"
isSensitive="false" />
<parameter name="Extended Properties" value="'Excel
8.0;HDR=Yes;IMEX=1'" isSensitive="false" />
</parameters>
</connectionString>

<connectionString name="textFileConnectionString">
<parameters>
<parameter name="Provider" value="Microsoft.Jet.OLEDB.4.0"
isSensitive="false" />
<!--
Notice the Data Source of a textfile is the DIRECTORY, not the full
path/filename
The Select statement looks like:
"Select * from mytextfile.txt"
-->
<!--
<parameter name="Data Source"
value="C:\Inetpub\wwwroot\DotNetAssemblies\GranadaCoder\Applications\BulkDat
aTransferExample\TextFilePubsEquiv\" isSensitive="false" />
-->
<parameter name="Data Source" value="..\..\TextFilePubsEquiv\"
isSensitive="false" />
<parameter name="Extended Properties"
value="'text;HDR=YES;FMT=Delimited'" isSensitive="false" />
</parameters>
</connectionString>



</connectionStrings>
 

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

Top