How to download an excel file from OneDrive (teams) using SSIS? - sql-server

I have an excel file on OneDrive (teams). I want to import the data from the excel file into SQL table. Which SSIS task can I use for this?
Here is what I have tried (https://www.techbrothersit.com/2016/07/how-to-download-file-from-sharepoint-by.html)
In Onedrive (teams), Share the file with everyone, copy link
In visual studio, create a new SSIS projects, Create new connection (HTTP) - this creates the HTTP connection manager
In the new http connection give the server url as the link copied from step 1
Click on test connection - error: The remote server returned an error: (403) Forbidden. Even if I enter my credentials then also I get the same error.
If I paste the link in web browser (incognito mode), then it opens the excel file in browser.
I also tried the OData connection manager, same error.
Other references (same error):
https://medium.com/#smitagudale712/download-excel-file-from-online-in-ssis-a830c32389f5
https://sqlis.com/Downloading-a-file-over-HTTP-the-SSIS-way/

Related

Prompt for new SQL Server credentials in Excel

I was creating a SQL query in excel via Data > Get Data > From Database > From SQL Server Database button. During the creation, I accidently attempted to create the source using windows authentication which will not work as I need to use SQL authentication and of course resulted in the expected error. When I try recreating the same connection to the same server it will not prompt any more for credential after adding the DB and Command and must be using the old credentials.
I tried creating a new workbook and it still will not prompt for new credentials.
I was able to successfully link another server which prompted for credentials but no longer will for the server in question.
Is there a file or location in Excel that is storing these credentials that I can remove them from? The troubled server/connection does not appear under the query/connection list in the workbook.
Any help is appreciated!
This is the error I receive and knew would occur when using the wrong credentials: Details: "Microsoft SQL: The target principal name is incorrect. Cannot generate SSPI context."

How to import dataset from SQL Server via VPN connection

I need to import dataset from a remote SQL Server using a VPN connection. I would like to know how to proceed. I have no experience in servers.
I am using a shiny app to read and process csv files. Now I am getting a bit more ambitious and I would like to upload directly my data from a remote SQL server. I communicate to this server via a VPN connection.
When you have access to the database via SSMS, You can import file.
you choose the database that you want to import file into.
right click the database and find "Import Data" option under
tasks.
You will be able to choose file type that you are
trying to import. For the Txt, and csv file, please use Flat File
Source as Data Source.

Auto generated connection string of (localDB)\mssqllocalDB is not working in mvc

In my ASP.NET MVC application, I have created the new ADO.net entity object & pointed to (localDB)\mssqllocaldb (the connection string created automatically, table name tblProduct). After adding new controller (e.g. Product) with this entity and trying to access the index page, I'm getting an error.
Note : I am able to connect to the database in SQL Server Management Studio and also able to see the database in DataConnections in the Visual Studio server explorer
Error :
Exception message: 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: 50 - Local Database Runtime
error occurred. Cannot get a local application data path. Most
probably a user profile is not loaded. If LocalDB is executed under
IIS, make sure that profile loading is enabled for the current user. )
Application log in Windows Log:
Cannot get a local application data path. Most probably a user profile is not >loaded. If LocalDB is executed under IIS, make sure that profile loading is >enabled for the current user.
Connection string
add name="productsContextV12" connectionString="metadata=res:///Models.products.csdl|res:‌​///Models.products.‌​ssdl|res://*/Models.‌​products.msl;provide‌​r=System.Data.SqlCli‌​ent;provider connection string="data source=(LocalDB)\mssqllocaldb;initial catalog=EMPDB2;integrated security=True;MultipleActiveResultSets=True;App=EntityFramew‌​ork"" providerName="System.Data.EntityClient" />
issue got resolved after replacing "DataResouce=(LocalDB)\mssqllocaldb" with "Server=np:\.\pipe\LOCALDB#2XXXX\tsql\query" in ConnectionString .
Server name holds instance pipe name ,this can be found using command :
c:> sqllocaldb info mssqllocaldb . below is the image for details .
Thanks to GuidoG for ur quick response
command for the instance details:
Your connectionstring is for LocalDB but the file is not set in the connectionstring. In stead it looks like you set the 'initial catalog' property to a database in some sql server.
For localDb you have to set the file containing the database, usually this is an MDF file.
This is what you need to do :
Create a textfile anywhere on your disk, and give it extension .udl
Now doubleclick on this file, the Microsoft datalink properties window will now open.
In this window configure everything until a click on 'test connection' succeeds.
Remember to choose
Attach a database file as a database name:
When this is done and 'test connection' returned success, then open the file in notepad and examen how the correct connectionstring should be in your case.

Cannot import data from Access to MS SQL Server

I am trying to migrate a vb.NET project from an MS Access database to MS SQL Server, and have been following a tutorial I found here to do so. I did this, but got a problem where I could read data from the SQL Server database when running my project, but could not insert/edit data using the project.
Any data I tried to manipulate only worked on the Access database, and didn't have any affect on the SQL Server data (I also tried vice-versa, adding data using SQL Server but this couldn't been seen in my project).
So I decided to try again, deleting the Access and SQL Server databases, and using the backup database to import the data from. However, this now is not working, and I'm getting the following error message
Error 0xc020801c: Source - ~TMPCLP123581 1: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "SourceConnectionOLEDB" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed.
(SQL Server Import and Export Wizard)
Exception from HRESULT: 0xC020801C (Microsoft.SqlServer.DTSPipelineWrap)
Does anybody know a fix for this? Or why I can no longer import data into SQL Server? (The image below shows the result of what processes were/weren't carried out)
I've fixed the issue now, guys.
I migrated it over using Microsoft SQL Server Migration Assistant for Access, and then changed the connection path and settings in my .ini file.
Then I created a new connection string, using string variables for each of the settings in the .ini file, and this replaced the initial Access database connection string.

How to test MSSQL Database Connectivity outside an application

Sometimes when trying to setup web.config and connectionstrings.config settings for our .NET applications we get DB errors. Many times due to wrong connection info in the config files. Sometimes we need to find out if the app/web server can even see the DB server.
How would you connect to your DB server to test connectivity before getting the app to run?
The answer that I have found is this:
There's a utility built into windows that will test SQL connections.
Here's a simple way to use it.
Create an empty file called anything.udl and double click on it. Click
the Provider tab, and select "Microsoft OLE DB Provider for SQL
Server". Then click the connection tab, populate your connection
details, and hit the "Test Connection" button.
Credit goes to this poster/forum about 3 posts down they post the above information.
So steps to do so are the following:
On your app/web server create a blank file called test.udl
Double-click this file and at least with Windows Server 2008 R2 it will open up a Data Link Properties window.
Insert your connection string information and hit the test button and it should connection successfully. If it doesn't then make sure your DB info is correct and if it is then your server might not be able to see the SQL server.
Hope this is helpful to others!

Resources