The below connection string establishes connection with excel file which has extension as '.xls' but same string throws an exception while opening a connection with file which has extension as .xlsx.
Any idea?
ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Users\abcd\Desktop\demo.xls; Extended Properties=excel 8.0; Persist Security Info=False
This is because you need a different connection string for xlsx'es.
Related
I have been able to successfully connect my excel to MS access, and using the connection, I am able to push and pull data to and from excel to Access DB. However, I noticed, if my connection string has space in between like mentioned below, I am unable to establish the connection. Is there any way around it?
Connection string with space
Set oADODBCon = New ADODB.Connection
oADODBCon.Open Microsoft.ACE.OLEDB.12.0;Data Source=\\XYZ-123\0123\ABC 2020 Test Operations\MyDb.accdb;Persist Security Info=False;
I have tried using single quotes in my connection string as below but it still didn't work
Set oADODBCon = New ADODB.Connection
oADODBCon.Open Microsoft.ACE.OLEDB.12.0;Data Source='\\XYZ-123\0123\ABC 2020 Test Operations\MyDb.accdb';Persist Security Info=False;
Any help would be much appreciated!
oADODBCon.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\XYZ-123\0123\ABC 2020 Test Operations\MyDb.accdb;Persist Security Info=False;"
we are currently retrieving data from our SQL Database for various purposes.
But we are shifting our Sql Database to a new Server. I need to change the Server link to the new server. I have tried changing the Server name in the Connection String at the Connection Properties window. But it doesnt work.
I have given the Connection Type Connection String details below for your reference.
The Server Name given in he below settings are Jr-erpsrv-02. I need to change this to Jr-erpsrv-03.
1) Connection Type : Database Query
DRIVER=SQL Server;SERVER=JR-ERPSRV-03;UID=Shakila;Trusted_Connection=Yes;APP=Microsoft Office XP;WSID=YFHO-WKSTATION
2) Connection Type : Database Query
DSN=Syspro;Description=Syspro;UID=ramya;Trusted_Connection=Yes;APP=2007 Microsoft Office system;WSID=ITSYSPRO-NB;DATABASE=SysproDSPL
3) Connection Type : Office Data Connection
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=SysproDSPL;Data Source=JR-ERPSRV-02;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=ACIT-PC1;Use Encryption for Data=False;Tag with column collation when possible=False
So I am trying to add my connection string to Azure for an Entity Framework Database First edmx file and it's not going so well.
My conn string in Web.Config:
<add name="MyEntities" connectionString="metadata=res://*/Models.MyModel.csdl|res://*/Models.MyModel.ssdl|res://*/Models.MyModel.msl;provider=System.Data.SqlClient;provider connection string="data source=MyDatabaseName.database.windows.net,1433;initial catalog=XXXXXX;persist security info=False;user id=XXXXXX;password=XXXXXXXXX;multipleactiveresultsets=False;connect timeout=30;encrypt=True;trustservercertificate=False;App=EntityFramework"" providerName="System.Data.EntityClient" />
My connection string in Azure:
"metadata=res://*/Models.MyModel.csdl|res://*/Models.MyModel.ssdl|res://*/Models.MyModel.msl;provider=System.Data.SqlClient;provider connection string="data source=tcp:MyDatabaseName.database.windows.net,1433;initial catalog=mydatabase;persist security info=False;user id=**************;password=**************;multipleactiveresultsets=False;connect timeout=30;encrypt=True;trustservercertificate=False;App=EntityFramework""
Please tell me what I'm doing wrong... I've looked at 5 posts that tell me to just cut and paste my connection string in there, but they don't mention is leading or trailing quotes are needed... Also not sure that it's going to work for an edmx... I've tried using "custom" also.
Thanks so much for any guidance!!
Assuming you are trying to configure a connection string directly in the azure portal for the webapp, you have to make sure of 3 things
1) Replace " with single quote (‘) from the original connection
string that is set in web.config so mine becomes
metadata=res://*/Clash.csdl|res://*/Clash.ssdl|res://*/Clash.msl;provider=System.Data.SqlClient;provider connection string='data source=server.database.windows.net,1433;initial catalog=db;user id=websiteadmin#server;password=************;MultipleActiveResultSets=True;App=EntityFramework'
2) Make sure that the connection string type is CUSTOM
3) Leave a dummy connection string configuration in the web.config like this
<connectionStrings> <add name="nextgenplusEntities" connectionString="dummy"providerName="System.Data.EntityClient"/>
If I remove the dummy connection string then things fail for me….
Server Error in '/' Application.
The connection string 'nextgenplusEntities' in the application's configuration file does not contain the required providerName attribute."
Hope this helps.
I'm trying to connect to an Oracle Database from an Excel application and whithout a DNS. I found on a website that it's possible to use ADO, so this is why I tried to do. I'm new to this so I juste copied what I found on this website.
Here is my code so far :
Sub ADOtest()
Dim connection As New ADODB.connection
connection.ConnectionString = "UID = user1; PWD= my_pwd; DRIVER = {Microsoft ODBC for Oracle; Server= localhost; Database= orcl.my_domain;"
connection.Open
End sub
When I run this code, I get an error saying that the driver was not found.
The problem is that I have no idea of what I have to do with the driver (how to install it and configure it). Plus, I don't know which one I should use : I've read that there is a driver from Microsoft, another one from Oracle and also I've seen something about providers like msdaora.
The program will be used by many users, so I would like to choose the solution that is the lightest (not much to install on computers).
Thank you !
For COM based ADO (ADODB) you can use the OLE DB Providers.
One is from Oracle, called "Oracle Provider for OLE DB". You can download it from 32-bit Oracle Data Access Components (ODAC) and NuGet Downloads (assuming your Excel is 32-bit). The connection string would be
"Provider=OraOLEDB.Oracle;Data Source=orcl;User ID=myUsername;Password=myPassword"
The other one is from Microsoft. Please note, this provider is deprecated, you should not use it for new projects. Usually it should be available on your Windows. Be aware, like the provider from Oracle it also requires an Oracle Client to be installed on the PC! The connection string would be
"Provider=MSDAORA;Data Source=orcl;User ID=myUsername;Password=myPassword"
The data source is usually defined in tnsnames.ora file or at a LDAP server, for example:
orcl.my_domain =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(Host = localhost)(Port = 1521))
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
If you don't have such entry you can put everything into the connection string, e.g.
"Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=localhost)(Port=1521))(CONNECT_DATA=(SERVICE_NAME=orcl)));User ID=myUsername;Password=myPassword"
Perhaps you have to enclose the data source value by double-quotes ("), I am not sure.
So, in any case you would have to install an Oracle Client at all PC's.
Where is your database server hosted? In your question you say Server=localhost;, this would be quite unlikely, i.e. it is in contradiction to The program will be used by many users. I doubt everybody has an Oracle Database server installed on his local host.
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;"