Connecting to MS-SQL from ASP Classic - sql-server

I followed these steps to create my connection string:
1) Right-click an empty spot on the desktop and choose NEW, TEXT DOCUMENT from the context menu
2) Save it with a .udl extension, and click yes when it asks are you sure.
3) Double-click the new udl file you just created. It will open a dialogue. Go to the Provider tab, and choose the appropriate provider.
4) Go to the Connection tab and fill in the server name and database name, and choose NT authentication (or use a specific username and password, which is SQL authentication). Now click Test Connection. If it works, you're ready to click OK and move on to the final step. If it doesn't you need to resolve permission issues, or you've mis-typed something.
5) right-click the file on the desktop and open it in notepad. It will display the connection string that you can copy and paste to wherever you need it.
This is the connection string I got:
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB.1;Password="&DatabasePass&";Persist Security Info=True;User ID="&DatabaseUser&";Initial Catalog="&DatabaseName&";Data Source="&DatabaseServer
I am getting this error :
Microsoft OLE DB Provider for SQL Server error '80004005'
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

If you pass the test connection in step 4, Make sure that you replace DatabasePass, DatabaseUser, DatabaseName and DatabaseServer with real values, when you copy-paste the code.

Related

SSRS - Unable to connect to datasource

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.

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.

Remove login prompt with SQL linked tables in Access

I have an issue similar to this one: SQL Server 2008: ODBC connection problems
But mine is unique because I already have the "Save Password" option checked when I link my tables, AND it works fine unless I try to open more than one query at a time.
Steps to recreate:
1) Link a SQL table to an Access 2003 front-end, my DSN looks like this:
[ODBC]
DRIVER=SQL Server
UID=ACD
WSID=ACD
APP=ACD
SERVER=xx.xx.xxx.xx,1053
Description=ACD Connection to SQL Server
Pwd=XXXXXXXX
At first I didn't have the PWD line, it doesn't seem to make a difference with or without that.
2) Open 1 query that uses the linked table, no login prompt
3) Open 2nd query while first one still open, get this error followed by login prompt:
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed.
The login is from an untrusted domain and cannot be used with Windows authentication.
I can open as many tables as I want directly and I don't get a password prompt.
If I login once, no more prompts until I restart Access, but this isn't an option for my app.
I'm using SQL server auth only, not setup for Windows auth.
You could try using a DSN-Less connection to your SQL server, microsft have a support page for this: http://support.microsoft.com/kb/892490
This should stop the prompts
You have to save the password in you connection (see parameter dbAttachSavePWD)
Dim MyTable As TableDef
Set MyTable = CurrentDb.CreateTableDef(TableName, dbAttachSavePWD, SourceTableName, ConnectionString)
CurrentDb.TableDefs.Append MyTabl
for example to attach sql table [audit].[Details] as AuditDetails you can use the following code:
Dim MyTable As TableDef
Set MyTable = CurrentDb.CreateTableDef
(
"AuditDetails",
dbAttachSavePWD,
"audit.Details",
"ODBC;DRIVER={SQL Server};APP=TransFlow®;SERVER=sqlServerName;DATABASE=dbName;UID=userName;PWD=password"
)
CurrentDb.TableDefs.Append MyTabl

Classic ASP - SQL Server 2008 Connection String using Windows Authentication

This should be painfully simple, but I cannot come up with a working connection string for a local copy of SQL Server 2008 using Windows Authentication. I've tried using the Data Link Properties tool to create a connection string and it has no problems connecting, but when I copy paste the generated string into my ADODB.Connection object's ConnectionString property I get all sorts of fun and different errors.
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = "SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=climb4acure;Data Source=(local);"
Microsoft OLE DB Service Components (0x80040E21)
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
I've tried a variety of similar connection strings but I cannot find one that will work with Windows Authentication. Can someone point me in the right direction?
Thanks!
Here's an easy way to generate connection strings that work.
Right-click an empty spot on the desktop and choose NEW, TEXT DOCUMENT from the context menu
Save it with a .udl extension, and click yes when it asks are you sure.
Double-click the new udl file you just created. It will open a dialogue. Go to the Provider tab, and choose the appropriate provider.
Go to the Connection tab and fill in the server name and database name, and choose NT authentication (or use a specific username and password, which is SQL authentication). Now click Test Connection. If it works, you're ready to click OK and move on to the final step. If it doesn't you need to resolve permission issues, or you've mis-typed something.
Now right-click the file on the desktop and open it in notepad. It will display the connection string that you can copy and paste to wherever you need it.
I assume you have the 2008 Native Client installed? Also, I noticed that you're missing the "provider" tag at the beginning - do you have any more luck with this one:
Provider=SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=climb4acure;Data Source=(local);
Have you had a look at connectionstrings.com? They are a pretty good reference (but, in my experience, they don't work too well in the Google Chrome browser).
Works absolutely fine:
"Provider=SQLNCLI;Server=xxxxxxxx;uid=sa;pwd=xxxxxx;database=xxxxxx;"

Resources