Errors connecting to an offline cube (.cub) file - c#

I've been searching for a solution to my doubt but couldn't find anything more relevant than an installation issue, which isn't a problem in my case.
I am trying to execute a C# project (similar to this) that creates a local cube (.cub) file and processes data taken from an existing processed cube on Analysis Services 2012.
The project runs correctly when I use a connection string for output cube that points (and hence writes) to another database on Analysis Services. But when I execute the project using the following connection string that points to the local cube file to be created, it gives me errors depending on the version of ADOMD library referenced.
conn.ConnectionString =
string.Format( "Provider=MSOLAP;Data Source={0}", "c:\\output\\mycube.cub" );
When referenced to ADOMD 11 library, I get the following errors:
OLE DB error: OLE DB or ODBC error: A network-related or instance-specific error has occurred while establishing a connection
to SQL Server. Server is not found or not accessible. Check if
instance name is correct and if SQL Server is configured to allow
remote connections. For more information see SQL Server Books Online.;
08001; Client unable to establish connection; 08001; Encryption not
supported on the client.; 08001.
Errors in the high-level relational engine. A connection could not be made to the data source with the DataSourceID of 'DB_NAME', Name of
'DB_NAME'.
When referenced to ADOMD 12 library, I get the following error:
A connection cannot be made. Ensure that the server is running.
Although, I know SQL Server Analysis Services are running when I checked in services.msc.

Figured it out. I was missing a reference to the assembly Microsoft.AnalysisServices.dll

Related

C#, Visual Studio 2022 update, error after publishing - provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified

There are a lot of similar questions here and I think I read all of them, but still haven't found the cause of this error:
provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified
The code:
string connection = Properties.Settings.Default.SqlConnection; 
SqlConnectionStringBuilder builder = new() 
{ 
["Server"] = connection, 
["Database"] = "myDatabase", 
["Trusted_Connection"] = true 
}; 
using SqlConnection conn = new(builder.ConnectionString); 
try 
{ 
conn.Open(); 
} 
catch (Exception ex) 
{ 
throw;
} 
finally 
{ 
conn.Close(); 
} 
I store myServerName\myInstanceName in the settings:
<add name="TestSQLConnection.Properties.Settings.SqlConnection" 
connectionString="Servername\SQL2012" /> 
This works on my local machine, but when I publish the application, the user will get the above mentioned error. If I log in and run the published application on the server, it works (but I am admin, so that is not a surprise) and strangely enough, after I run it, other users will be able to run it without error, but only temporarily (How is this possible?). I am having this issue since the latest update of VS2022, before that it worked and if I publish an older project now, the user gets the same error. All the applications I published earlier with the same connection string work just fine (which rules out most of the possible causes discussed here in earlier questions).
Things that I tried:
Make sure there is no typo in the connection string
Make sure that the server is reachable
Replace server name with IP in the connection string
Check if SQL Server Browser is running
Enable port 1433 in Server Configuration Manager
Add port 1433 to the connection string
Test applications published earlier with similar code (same connection string) and the same user.
Repair Visual Studio 2022
Any idea where should I try to look for the root cause would be highly appreciated. Can this be an issue with VS (I also tried to repair VS out of desperation, with no avail) or am I missing something trivial?
UPDATE
It is definitely an issue with the access rights. If I publish the application to a folder that is already in use for an application deployed before, it works. The funny thing is that there is no difference in security settings between the old and new folders. (same users/groups have the same access rights to the folders)

The provider did not return a ProviderManifestToken string - Cannot connect to MySql Hosts

I have a simple MVC app I'm working on. I'm trying to connect to a MSSQL server using Entity Data Model (code first from database). After successfully adding the data using the Entity Data Model Wizard, the code below throws the error "The provider did not return a ProviderManifestToken string". The inner exception is "Unable to connect to any of the specified MySql Hosts. The thing I can't figure out though, is I'm not using MySql anywhere in the project. Searching in the project explorer for "MySql" turns up nothing. Doing a Ctrl+F and searching for MySql also returns nothing found. My web.config only has the one connection string in it for the MSSQL server connection. What can I do to figure out why my project is trying to connect to this unknown MySQL server?
My code:
string something = kyg.Products.FirstOrDefault(m => m.ItemNo == "128676").ShortDescription.ToString();
I don't have an issue with the MSSQL server - I have many apps that are running successfully on the same connection. I just can't find this unknown reference to a MySql server. Any Ideas on where to look/what to try?
Edit
I felt it is worth mentioning that I inherited this project, and can't confirm what development was done on it prior to me taking it over. Also, I was looking through the files, and did find MySql.Data.dll, MySql.Data.Entity.EF6.dll, and MySql.Web.dll. I moved these files out of the bin folder, and now receive a different error -
File Not Found - Could not load file or assembly MySql.Data.Entity.EF6.dll - so something is trying to reference that dll, I just can't figure out what or where it is coming from.
Thanks in advance,

C# app with SqlClient does not work on another computer

I have written an application that uses SqlClient and a local mdf database. However, it does not work on another machine (throwing an exception that the server cannot be run) and I assume this is because there is no SQL server installed? But I thought that using local database and SqlClient elimites the need for the server, something like the old SQL CE. Is that the problem?
EDIT Exception: System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while extablishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections
As for connection string, I keep the one generated by Visual Studio Express, just modify the path to use the app folder.
SqlConnection s = new SqlConnection(#"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename ="+ System.IO.Path.GetDirectoryName(Application.ExecutablePath)+ #"\Database1.mdf; Integrated Security = True");
Is there a simple way how to rework this so that my app does not require SQL server installed? All I need is to have it use the local database file in its folder.

ADOMD Connection Error

I am receiving the following error from ADOMD while trying to connect to my SSAS Server.
An unhandled exception of type 'System.Xml.XmlException' occurred in
Microsoft.AnalysisServices.AdomdClient.dll
Additional information: Element 'return' was not found. Line 5,
position 2.
I can confirm the following:
My Connection String Is:
Data Source=<MyServer>;Catalog=<My SSAS DB>; UID=<MyDomain>\<MyDomainUser>;PWD=<MyPassword>;
I can confirm that my connection string is correct ( or at least the data I am using in the connection string above is correct). If I change any part of the connection string to an incorrect value the ADOMDConnection will return "Cannot connect to server". I have also looked at the audit logs on the server itself and confirm that I am successfully logging onto the server. And the contrary, with incorrect credentials the server logs confirm a failed login.
I am trying to connect to SSAS 2014 Enterprise
The failed connection returns within a few seconds. A few posts out on the internet suggest increasing the Connection Timeout property. This does not seem to be my issue as I have increased it to 120 and its failing within 5.
I am using ADOMD 12.0 Runtime 2.0.50727
My domain user is a domain admin and has been added to an admin role in the SSAS.
Im not sure what else could be wrong or how to debug this or is this a known bug in ADOMD?
Any advice would greatly appreciated.
thanks!
Jason
This happens routinely when the version of the ADOMD client DLL is not a version that matches the target version of the server instance. For example, Azure Analysis Services as of 09/13/2017 does not work with Microsoft.AnalysisServices.AdomdClient.dll version 13. Only version 14 and above.
For reference, the ADOMD DLL for Azure Analysis Service is available in the link below:
https://learn.microsoft.com/en-us/azure/analysis-services/analysis-services-data-providers
Double check to make sure the client DLL is the exact version needed for the target server instance. That solved this exact issue in my case.

Visual Studio 2013 DB creation error : a network related or instance specific error occurred while establishing connection with sqlserver

First of all, let me tell you that I have tried every damn thing by Googling to overcome this error and I have not done any TYPO error either. But, none of the Google results helped. Let me tell you the scenario... I installed Visual Studio Ultimate 2013 (and nothing else, no separate sqlexpress, nothing). All non-DB apps are working fine. But, for one project, when I tried to create new database connection (by right clicking 'data connections' or clicking 'connect to database' icon for creating localdb), I got this error:
"A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (Provider:
sqlnetwork interfaces, error 26- Error locating server/Instance
specified)"
Then, as usual, I tried to Google for it. But most of the answers were related to sqlexpress (which I didn't installed separately). Then one answer was about "sqlserver configuration manager" and enabling sqlservices and something called surface area.... But, as "sqlserver configuration manager" was not there in my 'all programs' on my windows 8 (64x) machine, I downloaded sqlexpress and sqlserver management studio too. But an item named something like "surface area manager...." was not there. I enabled sqlservices, all tcp/ip ports. Shut down my firewall. Still getting the same error.
NOTE: I dont have any connection string in my webconfig till now because I was just going to create the new DB. So the the answer about editing conn string doesn't mattered to me.
NOTE: This was not the case with Visual Studio 2012. On only VS2012 (and nothing else) installation, it worked fine for creating the DBs and all other things. So, what's wrong with VS2013??
Server \ Instance name must be reachable from your client, as the creation of the connection string will try to verify that it connected OK. Try this from your workstation:
sqlcmd -Sservername\Instance_or_IPaddress_of_Sql_server -E -Q"select ##version"
Until you get a proper server name or instance, you will not be able to successfully create a db connection.

Categories

Resources