connection string error to sql server 2012 - c#-4.0

I try to connect my c# application to sql server 2012
my connection string is
connectionString="Server=.\MSSQLSERVER; Database=|AppData|\TechnicalOfficeManagerDB.mdf; Trusted_Connection=True;"
the application raise exception said
the value's length for key exceeds it's limit of '128' and don't connect to sql server
I don't understand what is the problem?

Please have a look this website : http://www.connectionstrings.com/
There is an example here : http://www.connectionstrings.com/sql-server-2012/
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname;
Trusted_Connection=Yes;
Try removing "\" after AppData
connectionString="Server=.\MSSQLSERVER; Database=|AppData|TechnicalOfficeManagerDB.mdf; Trusted_Connection=True;"

Related

How to create the connection string for a database generated with pgAdmin4

I developed my app with SQLAlchemy testing it on an SQLite database.
Now I would like to testing more using PostgreSQL but in a localhost once again.
For this reason, I tried to create a local Postgre database with pdAdmin4 (my laptop has Windows 7 so I installed the v4 version of the database manager).
Now I am trying to generate the connection string for this Postgre database but I cannot understand how to do it.
This is what I created in pgAdmin4:
while the details of the server are these:
The connection string I am trying to use is this:
selected_engine = create_engine('postgresql+psycopg2://postgres:123#localhost/test_server/test_database')
The password 123 is the password I set at the first access to pgdAmin4.
However, I got this error:
OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5432 failed: FATAL: database "test_server/test_database" does not exist
I am sure I am wrong and I cannot figure out what is the correct URL for my database.

Connecting to Azure PostgreSQL server from python psycopg2 client

I have trouble connecting to the Azure postgres database from python. I am following the guide here - https://learn.microsoft.com/cs-cz/azure/postgresql/connect-python
I have basically the same code for setting up the connection.
But the psycopg2 and SQLalchemy throw me the same error:
OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
I am able to connect to the instance by other client tools like dbeaver but from python it does not work.
When I investigate in Postgres logs I can see that the server actually authorized the connection but the next line says
could not receive data from client: An existing connection was forcibly closed by the remote host.
Python is 3.7
psycopg's version is 2.8.5
Azure Postgres region is in West Europe
Does someone has any suggestion on what should I try to make it work?
Thank you!
EDIT:
The issue resolved itself. I tried the same setup a few days later and it started working. Might have been something wrong with the Azure West Europe.
I had this issue too. I think I read somewhere (I forget where) that Azure has an issue with the # you have to for the username (user#serverName).
I created variables and an f-string and then it worked OK.
import sqlalchemy
username = 'user#server_name'
password = 'PassWord!'
host = 'server_name.postgres.database.azure.com'
database = 'your_database'
conn_str = f'postgresql+psycopg2://{username}:{password}#{host}/{database}'
After that:
engine = sqlalchemy.create_engine(conn_str, pool_pre_ping=True)
conn = engine.connect()
Test it with a simple SQL statement.
sql = 'SELECT * FROM public.some_table;'
results = conn.engine.execute(sql)
This was a connection in UK South. Before that it did complain about the format of the username having to use #, although the username was correct, as tested from the command line with PSQL and another SQL client.

SSAS excel remote connection

I migrated to SQL Server 2014 from 2008 version. I have Windows Server 2012 with IIS 8.5.
I'm trying to configure remote access to my OLAP database . I followed all the steps as described here:
https://msdn.microsoft.com/it-it/library/gg492140(v=sql.120).aspx.
The IIS version mentioned is the 8.0, does it fit for the 8.5 too?
When I try to test the configuration using the Management Studio I get this error:
TITLE: Connect to Server
Cannot connect to http://localhost/OLAP/msmdpump.dll.
ADDITIONAL INFORMATION:
The connection either timed out or was lost. (Microsoft.AnalysisServices.AdomdClient)
The remote server returned an error: (405) Method Not Allowed. (System)
Program Location:
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.EndRequest()
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.SendMessage(Boolean endReceivalIfException, Boolean readSession, Boolean readNamespaceCompatibility)
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.Discover(String requestType, String requestNamespace, ListDictionary properties, IDictionary restrictions, Boolean sendNamespacesCompatibility)
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.SupportsProperty(String propName)
at Microsoft.AnalysisServices.AdomdClient.XmlaClient.Connect(ConnectionInfo connectionInfo, Boolean beginSession)
at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Connect(Boolean toIXMLA)
at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Microsoft.AnalysisServices.AdomdClient.AdomdConnection.IXmlaClientProviderEx.ConnectXmla()
at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.ConnectToXMLA(Boolean createSession, Boolean isHTTP)
at Microsoft.AnalysisServices.AdomdClient.AdomdConnection.Open()
at Microsoft.SqlServer.Management.SqlStudio.Explorer.ObjectExplorerService.ValidateConnection(UIConnectionInfo ci, IServerType server)
at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()
===================================
The remote server returned an error: (405) Method Not Allowed. (System)
------------------------------
Program Location:
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.AnalysisServices.AdomdClient.HttpStream.GetResponseStream()
at Microsoft.AnalysisServices.AdomdClient.HttpStream.GetResponseDataType()
-----------------------------------------------------------------------------------------------------------------
What can I do to get more details in order to find what goes wrong?
Thank you in advance for your help!

SSIS package from ASP.net does not work on client but does on server

Description Of Environment
I have an SSIS task which executes from asp.net, the package gets data from excel files over UNC path and puts the data into a sql server databaase . I have deployed the SSIS to file system, it has windows authentication database connections and the IIS user has database access. I can log in as the AppPoolUser I have used to host the web application and open/modify the files in question so those basic permissions are there. Web App is compiled in x86.
When it works:
When run from web app in browser on server under my user or appPool user
When logged in as me on server running through BIDS
When logged in as AppPoolUser on server running through BIDS
When run from scheduled task on server using AppPoolUser
When it doesn't work:
When run from client browser i.e. not the machine that has IIS hosting the asp.net app
My Question
What is different about the client and server and how do I make it work? I was under the impression that when running the web app all connections go through the AppPool User so it should behave the same on any machine server included?
The Error returned to client browser
SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft Office Access Database Engine" Hresult: 0x80004005 Description: "The Microsoft Office Access database engine cannot open or write to the file '\\myserver\My folder\myfile.xlsx'. It is already opened exclusively by another user, or you need permission to view and write its data.". SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "MyExcelFileConnection" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed. component "Excel Source" (1) failed validation and returned error code 0xC020801C. One or more component failed validation. There were errors during task validation.
c# Code running SSIS Package
string pkgLocation;
Package pkg;
Application app;
DTSExecResult pkgResults;
string result = string.Empty;
string dtsErrors = string.Empty;
try
{
pkgLocation = packagePath;
app = new Application();
pkg = app.LoadPackage(pkgLocation, null);
pkgResults = pkg.Execute();
foreach (DtsError local_DtsError in pkg.Errors)
dtsErrors += " " + local_DtsError.Description;
result = pkgResults.ToString();
}
catch (Exception exception)
{
result = exception.Message;
}

ASP 80004005 error on IIS 7.5

We are trying to run an ASP application on windows 2008 R2 standard (64 bit processor & iis 7.5). ASP application connects to MS Access database. IIS is running fine and Asp is running fine. But when ASP code tries to connect to MS-Access DB, its giving 500 error.
FilePath C:\INETPUB\WWWROOT\XXXXXX\XXXXX_SECTIONS.ASP
LineNumber 14
CurrentStatement LevelTop.Open()
ErrorCode 80004005
Error is coming exactly while opening connection to MS Access DB.
We checked with Process Monitor utility. I have attached the log file of process monitor. We assumed its a permission issue and granted all permissions, but still we are getting same error.
We even tried giving administration group user as IIS user. But still getting same issue.
[Edit]
Ok thanks joel. I am newbie to this environment.
I checked this link and installed this http://www.microsoft.com/downloads/en/details.aspx?FamilyID=C06B8369-60DD-4B64-A44B-84B371EDE16D.
Now I am getting this error
*ErrorCode: 800a0e7a
Description: Provider cannot be found. It may not be properly installed *
this is my connection string
"Provider=Microsoft.ACE.OLEDB.12.0;DBQ=C:\inetpub\wwwroot\xxxxx\App_Data\xxxxx.mdb;Persist Security Info=False;"
Set ThisSection = Server.CreateObject("ADODB.Recordset")
ThisSection.ActiveConnection = ConnectionString
ThisSection.Source = "SELECT * FROM table WHERE ID = " + Replace(ThisSection__MMColParam, "'", "''") + ""
ThisSection.CursorType = 0
ThisSection.CursorLocation = 2
ThisSection.LockType = 1
ThisSection.Open() ->** getting error exactly at this line**
The error message is that the provider cannot be found.
Two sources of this error could be:
Access is not installed
Access 32bit is installed and IIS is looking for the 64bit version, or the other way around
There should be an error in your eventlog.
Also you could try a restart after the installation of the Access driver.

Resources