SSRS - Unable to connect to datasource - sql-server

Context: I have an installation of SQL Server 2019 installed on my local workstation and within an SSRS Report Project I'm trying to create a dataset that connects to this SQL Server datasource. I keep raising this error
"Unable to connect to datasource 'XXXX'"
EDIT: I realized clicking through the details there's a more descriptive message here: You have specified integrated security or credentials in the connection string for the data source, but the data source is configured to use a different credential type. To use the values in the connection string, you must configure the unattended report processing account for the report server.
I'm thought I was using Windows Authentication. This is a very strange error because prior to this step when I create the datasource and test the connection the test succeeds. How is it that the datasource connection properties dialog recognizes the server, database name and successfully authenticates my windows creds in the connection test but suddenly the dataset dialog cant connect...?
How have I tried to fix this: I thought this could be an issue with the ODBC driver I'm using so I've installed both Microsoft ODBC Driver 13.1 & 17 for SQL Server which is not resolving the issue.
Question: Does anyone know why this is happening and how to fix it?

Answer: Turns out under the "Shared Data Source Properties" dialog box, within the "Credentials" tab, the radio dial for "Use Windows Authentication (integrated security)" needed to be selected.
I assume the reason the connection test succeeded was because SSRS guessed at the correct authentication method, but it still needs to be explicitly selected for the dataset to connect properly.

Step 1:- Click on Data Source
Select Add Data Source
It show two options in Left corner of Data source property window called General and Credential.
Select Credential.
Note (if Use Windows Authentication(Integrated security) is already selected also DO not Press Ok Follow Below Procedure steps.
First choose Do not use Credentials(Radio Button) and Do not press Ok.
then select Use Windows Authentication(Integrated security) Press OK.
Now Data source1 is Created.
Step 2:-Click Right Button on Data Source which is New created -> Select (Data Source Property)
Click Embedded Connection Radio Button
Select Type as: Microsoft SQL Serve
For Connection String Click on BUILD/EDIT Button
In Connection Property Enter your Server Name (Sql Server Name)
Select or enter name select Database name
Click Test Connection Click Ok
Once this is completed.
Step 3:-Right click on Date Source Which you are Created
Click on ADD DATASET
In Data Set Properties Enter Dataset Name
Select Data Source which you created.
Enter Query or Select Query designer and Click Ok.
Note Please follow Step 1 Properly this work only for Windows Authentication.
If you Have any Doubts Mail Me My Mail ID:- Harshithwight83#gmail.com.

If you're using Visual Studio to design SSRS reports:
Double-Click the data source file on the right side of the screen in the Solution Explorer window.
Click "Credentials"
Select "Use Windows Authentication (integrated security)
Click "OK"
It should work now.

Related

Connecting Excel VBA to oracle DB using 'ODBC'

Basically i work in a software company.
My client has a Oracle database.
I do access that database through SQL Developer.We have a virtual desktop too -inside which we have all client applications,SQL Plus etc..!!
Now one other person in my team has created a excel macro in which if you give your username password and your SQL query, it will connect to the oracle database and fetch the records for you and will save it in an excel sheet in the virtual desktop itself.
Now i want to do something similar but i am not able to fins how i connect my excel VBA to Database. As his macro is able to connect to the database i am pretty sure all necesaary drivers are installed in our virtual machine(desktop).
I can see "Oracle - OraClient11g_home1" in All programs in my virtual machine.I can see SQL plus and all those apps. Giving all these details because i read in other posts that these things may be required to connect to DB.
In SQL Devloper if i go to connection properties it shows me the Network Alias name as "xxxxxx"(I have replaced by xx).Connection type as 'TNS' and role as 'Default'.I know my username and password.
Note: In Excel when i go to new connect database option, i dont see Oracle Driver at all:( I can see only "Microsoft Driver for Oracle".
These are all the details i know . Can someone help me with connecting to Database.Once someone can help me do it rest everything i can do in my macro.:)
I just tested it following these steps:
Excel > Data > Get External Data > From Other Sources > From Data Connection Wizard
From Data Connection Wizard, select "Other/Advanced" and click Next
On the Connection tab, create new connection string by click on Build
On Machine Data Source tab, click New
Select Oracle driver
Enter corret "TNS Service Name" and your user id. Click test connection and enter your password.

How to connect to SQL Server database with C++ Builder

How can I connect to a SQL Server Database using C++ Builder?
When I drop SQLConnection component, I can't find a place to drop my connection string in... And how can I type a connection string in C++ Builder? Is it the same that in C#?
Use ADO components. You can use TADOConnection component where you can input your connection string and then add TADOTable for each database table or TADOQuery for SQL queries. Both TADOTable and TADOQuery have a Connection property where you will chose your TADOConnection component.
Once you have the TADOConnection component in your VCL form or Database form, you can click on the link in the Properties window to Edit ConnectionString. Otherwise you can right click on the object in the form and click Edit ConnectionString there. A ConnectionString dialog box will be displayed that lets you either connect to a data file or Use a Connection String. You want to use a connection string. There you can either paste in your old connection string and see if it works or use the Build... button on the right to select a provider such as SQL Server Native Client 11.0, then click Next>>. Then in the Connection tab select all the connection parameters and use the Test Connection button to actually test it. This is much better than trying to debug the connection in your application. Once it is working, save it by clicking on the OK button.
To connect to a MySQL server, drop a TSQLConnection component (in the
DBExpress palatte page) to your form, chose the ConnectionName as
MySQLConnection, DriverName as MySQL and set the Params according to this:
-if you are connecting to your local computer:
HostName - localhost (or 127.0.0.1 or your local computer name)
-or if you are connecting to a remote computer:
HostName - (your remote server's domain name)
-These will be same regardless of local or remote connection:
Database - (the database name you want to connect to)
User_Name - (your database user name, or log in name)
Password - (the password to access your database)
You can leave the rest at default unless you have other requirements.

determine SQL server 2012 connection string

i need to connect to SQL server from node so i need connection string.
How to define connection strings in SQL server 2012 ? or what are the ones by default ?
I'm not sure whether I get your question right...
Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;
Is that what you are looking for?
The server/instance name syntax used in the server option is the same
for all SQL Server connection strings.
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;
Password=myPassword;
You can create a new universal data link file (.udl) on your computer and double click the file in order to select provider and enter connection data. This way, you can test the connection and modify the settings accordingly.
Create a new file a.txt for instance, and rename this file to a.udl
Then follow the steps below to configure connection
Double-click the universal data link (.udl) file. The Data Link Properties dialog box opens, displaying the following tabs: Provider,
Connection, Advanced, and All. Choose Next to navigate from tab to
tab.
On the Provider tab, select a database provider.
On the Connection tab, either select the data source name (DSN) of an available Provider, or enter a custom connection string. Valid DSNs
for providers that are pre-defined on your system are displayed in the
Use Data Source drop-down list.
Use the Advanced tab to view and set other initialization properties for your data.
5.Use the All tab to review and edit all OLE DB initialization properties available for your OLE DB provider.
Choose OK to save the connection string to the Universal Data Link (.udl) file.
Then open up the file with a text editor to access the connection string stored.

Prompt for SQL Server to connect to in Visual Basic 2010

I have a project that current uses a hard coded SQL connection string. I want to make this more flexible so that when I move it to another environment the user can browse for the SQL server to connect to since it will have a different than my test server. I have tried countless ways to Google for a solution and I am just not getting any hit. I am looking for something similar to the open file dialog in VB, except for SQL servers, where it will list all the servers available on the network and let the users select one, then enter credentials.
Does such a thing exist?
Thanks!
It should be easy to develop a dialog box similar to one SQL Server Management Studio uses. Be aware that all instances on the network cannot be enumerated because broadcast packets are not typically routed and due to firewalls so you'll need to allow the user to enter a server name in the combobox. Here's a code snippet to return a DataTable of the found instances (http://msdn.microsoft.com/en-us/library/a6t1z9x2(v=vs.110).aspx):
Dim dt As DataTable = System.Data.Sql.SqlDataSourceEnumerator.Instance.GetDataSources
Below is a screenshot of the login dialog from SSMS. Just populate the server name combobox with the server and instance names from the data table, and add the other needed controls.

How to connect a new query script with SSMS add-in?

I'm trying to create a SSMS add-in. One of the things I want to do is to create a new query window and programatically connect it to a server instance (in the context of a SQL Login). I can create the new query script window just fine but I can't find how to connect it without first manually connecting to something else (like the Object Explorer).
So in other words, if I connect Obect Explorer to a SQL instance manually and then execute the method of my add-in that creates the query window I can connect it using this code:
ServiceCache.ScriptFactory.CreateNewBlankScript(
Editors.ScriptType.Sql,
ServiceCache.ScriptFactory.CurrentlyActiveWndConnectionInfo.UIConnectionInfo,
null);
But I don't want to rely on CurrentlyActiveWndConnectionInfo.UIConnectionInfo for the connection. I want to set a SQL Login username and password programatically.
Does anyone have any ideas?
EDIT:
I've managed to get the query window connected by setting the last parameter to an instance of System.Data.SqlClient.SqlConnection. However, the connection uses the context of the last login that was connected instead of what I'm trying to set programatically. That is, the user it connects as is the one selected in the Connection Dialog that you get when you click the New Query button and don't have an Object Explorer connected.
EDIT2:
I'm writing (or hoping to write) an add-in to automatically send a SQL statement and the execution results to our case-tracking system when run against our production servers. One thought I had was to remove write permissions and assign logins through this add-in which will also force the user to enter a case # canceling the statement if it's not there. Another thought I've just had is to inspect the server name in ServiceCache.ScriptFactory.CurrentlyActiveWndConnectionInfo.UIConnectionInfo and compare it to our list of production servers. If it matches and there's no case # then cancel the query.
Just in case anybody else is searching for a way to create and connect a query window programmaticaly - a short example for SSMS 2012:
UIConnectionInfo u =new UIConnectionInfo();
u.ServerName = "TestPC\\ServerInstance";
u.ServerType = new Guid("8c91a03d-f9b4-46c0-a305-b5dcc79ff907");
u.AuthenticationType = 0;//Use AuthenticationType = 1 for SQL Server Authentication
u.AdvancedOptions.Set("DATABASE", "AdventureWorks2012");
IScriptFactory scriptFactory = ServiceCache.ScriptFactory;
if(scriptFactory != null)
{
scriptFactory.CreateNewBlankScript(ScriptType.Sql, u, null);
}
This code snippet will open a new query window connected to specified server and database with windows auth.
I have not found a way to do this, since there appears to be no way to hook into the connection dialog window.
what are you working on?
EDIT:
If i understand correctly you want to intercept the query being run and if it matches the production server cancel it else send the text and results to a db?
hmm... while this would be possible but is a real major pain in the behind, and i wouldn't use an add-in for this. plus an add-in can be disabled, uninstalled etc.
you better try doing this with proper security setup on your production server.
I haven't tried this yet but didn't know if you have given it a shot.
Microsoft.SqlServer.Management.Smo.RegSvrEnum.UIConnectionInfo u =
new Microsoft.SqlServer.Management.Smo.RegSvrEnum.UIConnectionInfo();
Should allow you to make your own connection. But like I said, I haven't tested it yet.
You'll need a reference to Microsoft.SqlServer.RegSvrEnum.dll.
Let me know if it works.

Resources