Connecting to local SQL Server ASP.Net Core Entity Framework from Excel 2016 - entity-framework

I am working with Visual Studio 2017 and have an MVC app that uses Entity Framework that creates a local SQL Server database for the Entity stuff.
What I am trying to do is to connect to that database from Excel.
I have the connection string form the database, but can't seem to get Excel to create an ADODB connection to it. I am getting a Run-time error '-2147217887 (80040e21): Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. It is failing on the cn.Open below. Any help would be appreciated.
Dim cn As New ADODB.Connection
strCon = "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=PropertyValContext-57e4e5c8-9272-493b-ab16-74faf5d4318f;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
cn.Open strCon

Related

I am having trouble creating DB in SQL Server Express with Entity Framework Core 2.0

I am going through the MvcMusicStore tutorial on the www.asp.net website.
I am able to use Entity Framework Core 2.0 and migrations to create a DB in localDb.
Here is the connection string from that in appsettings.json:
"MvcMovieContext": "Server=(localdb)\\mssqllocaldb;Database=MvcMovieContext-19840e0a-5fb4-409c-9f38-7f2946cd3937;Trusted_Connection=True;MultipleActiveResultSets=true",
When ever I do these tutorials I usually at this point once the DB is created and everything works switch to SQL Server Express, because this is how I actually develop my projects.
So Entity Framework checks the new connection string, doesn't see the DB exists, and creates the new DB based on the Model.
But I can't seem to get the connection string to SQL Express working.
Here is what I have tried so far:
"MvcMovieContext": "Server=MyComputerName\\SQLEXPRESS;Database=MvcMovie;Trusted_Connection=True;MultipleActiveResultSets=true"
and
"MvcMovieContext": "Data Source=.\\SQLEXPRESS;Initial Catalog=MvcMovie;Integrated Security=True;MultipleActiveResultSets=true"
Both give the same result. The dreaded message:
SqlException: Cannot open database "MvcMovie" requested by the login. The login failed.
Login failed for user 'Domain\smiller'.
I installed SQL Server Express in Mixed Mode so Windows Authentication works and I made my 'Domain\smiller' account a DbCreater in Server Roles.
Just can't seem to get it.
I needed to run:
Update-Database
I went through this last year:
Why is dotnet ef not able to create a database against SQL Server Express?
It seems I never learn.

OLE DB provider for ADO.NET data source

I have an application which can connect to OLE DB data sources, however, my proprietary database has only ADO.NET provider.
Is there any ADO.NET to OLE DB bridge which could helps me to connect to ADO.NET data source?
EDIT:
I do not have control on application. It is some kind of reporting service. Here is how I expect to connect:
App <-> OLE DB Provider <-> (bridge?) <-> ADO.NET Data Source
Everything is running on Windows machine
You didn't mention the platform so I am going to assume things and point you to some direction.
For the .NET Framework Data Provider for OLE DB, the connection string
format is identical to the connection string format used in ADO
For more details you can refer to this page to get started:
Connecting to an OLE DB Data Source Using ADO.NET
And also it wouldn't hurt to have a look at this title Connecting to an OLE DB Data Source
in the following MSDN article (.NET 4.5)
Establishing the Connection
Update
On the other hand to access a ADO.NET data source using an OLE DB you can follow this example.
However if you mean by the word "bridge" to have something like
using (SqlConnection connection = new SqlConnection(oleConnectionString))
where, oleConnectionString is an originally an OLE connection string which is converted to act as an SQL connection string?! I am not sure if that's possible.
ADO.NET Sample

How to switch from LocalDB instance to SQL Express?

I created an SQL Express database and built an Entity Data Model off of it using the wizard, then used the Repository Pattern to generate a helper class that does my querying for me.
Unfortunately what I didn't realize is that Code First creates a localdb copy and basically ALL my add/removes now go to this ethereal location that I can't find so I can't run queries off the data in SQL Express. Now I know the data is being saved because I'm able to check the underlying model through breakpoints and queries during page load with using(Context = new Context()) { /query stuff/ }, but I don't know how to switch from the underlying model back to my SqlExpress instance.
Any thoughts?
LocalDb is just another sql server database, which is started by Visual Studio. It's data most of the time are in %USER% directory and you can open it with Sql Server Management Studio. To switch your project to your sql express instance, you need to change the connection string, that's all.

Crystal Reports against OLAP / XMLA / SimbaO2X-server

I'm trying to convert some old Excel-reports to Crystal Reports. The excel sheets uses OLAP-cubes and connects to a database using a XMLA connection over a SimbaO2X driver.
I just can't figure out which connection settings to use in Crystal Reports to be able to connect to the database.
I've tried both XML and OLAP connections, but just can't get a database connection.
Any help with the connection setting would be appreciated!
Edit: The database is a bit of a black box; it's probably an Oracle database (it was an Oracle database before the end user frontend was rewritten in java. They could have changed the database as well.) I have however no success with neither the Oracle Server nor the Microsoft OLE DB for Oracle connection method.
I have also this morning found a SimbaO2X provider under the OLE DB folder. While not working it's the best so far -- it accepts the username and password and lets me select which database to connect to but then fails with ADO Error Code: 0x80040e73 (Format of the initialization string does not conform to the OLE DB specification.) At least I have something to go on.
I'm running Crystal Reports XI if someone needs to know.
Partial solution:
Upgrade Crystal Reports XI to Release 2, service pack 4.
Update from service pack 4 to service pack 6.
Upgrades and updates can be downloaded from the SAP Community Network
A connection can now be made with the SimbaO2X OLE DB driver. This solution should also resolve connection problems with some other databases as well.
However, adding a table to the report results in a 0x800a0cc1 error (Item cannot be found in the collection corresponding to the requested name or ordinal)

Unable to run my app again after opening my database with the Server Explorer

I successfully use EF4 to build my database from scratch. My database is an SQL EXPRESS database file. I can manage this one with Sql Server Management Studio. So far so good.
I noticed that if I open my database with the Server Explorer in Visual Studio, the next time I run the application I got errors.
I also noticed that a new log file has been created. So now I have 2 log files.
Below is my connectionstring:
<add name="DocumentManagerEntities"
connectionString="data source=.\SQLEXPRESS2008;Initial Catalog=DocumentManagerDB;AttachDBFilename=|DataDirectory|DocumentManagerDB.mdf;Integrated Security=SSPI;MultipleActiveResultSets=True"
providerName="System.Data.SqlClient" />
What's wrong?
Thank you very much.
That maybe because multiple applications are trying to use your database at once. You need to close one connection to open another.
This article notes that
SQL Server Express Edition allows only a single connection to an .mdf
file when you connect with a connection string that has User Instance
set to true.
Further more
When you connect to a local database project, Visual Web Developer
connects to the SQL Server Express Edition database with user
instances enabled, by default. For example, the following code example
shows a typical connection string used by Visual Web Developer to
connect to a SQL Server Express Edition database.