Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 78072

Cannot connect to database programatically

$
0
0

Hello,

I'm having some issue connecting to a database. I'm using a Microsoft Access db and the standalone report designer. However, it is a requirement that I overwrite the data source's database connection programatically so that it is always using my WPF application's database ConnectionString in the app.config.  Using the standalone report designer is required because the client will be creating new reports and then previewing them, but ultimately dropping the report files on many machines which may have different db paths.

What DOES work is if embed my db connection in the report designer wizard - then the report will successfully show up in my application. However, this doesn't solve my issue of needing to use the app.config connection string.

My connection string looks like so:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MyDatabase.mdb;

My code to change the datasource:
 

<p>var reportSource = new UriReportSource();<br>            reportSource.Uri = @"Reports/MyReport.trdp";</p><p>//Uses reportPackager.Unpackage<br>            var reportInstance = UnpackageReport(@"Reports/MyReport.trdp");<br>            var dataSource = new SqlDataSource();            <br>            dataSource.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;<br>            dataSource.ProviderName = "Microsoft.Jet.OLEDB.4.0";<br>            reportInstance.DataSource = dataSource;<br>// Creates an InstanceReportSource<br>            var instanceReportSource = CreateInstanceReportSource(reportInstance, reportSource);<br>            this.ReportViewer1.ReportSource = instanceReportSource;      </p>

 

I get the error "Unable to find the required .Net Framework provider. It may not be installed."

How can this be true if I can otherwise access the same database using that connection string elsewhere in the application? And the embedded connection string will work correctly?

I'm hitting a wall here. I have seen other threads mention downloading the newest JET service pack but even Microsoft's support site says I should already have it (https://support.microsoft.com/en-us/kb/239114). I am on a 64 bit Windows 8 machine, and have my solution compiling to a 32 bit application.

Any help would be appreciated. Thank you!!


Viewing all articles
Browse latest Browse all 78072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>