Can't connect to Visual Studio 2015 SQL DB using Excel? - sql-server

!
I've tried using ADODB connection string and also in the Excel Data Connection Wizard.
I'm getting this error:
[DBNETLIB][ConnectionOpen(Connect()).]SQL Server does not exist or access is denied.
I can see the server created in Visual Studio with its databases fine, no worries, in SQL Server but not connect in Excel. I can connect in Excel to databases created in SQL Server but not those created in VS (2015).
It's seems like a server issue rather than database one but here's the connection string's anyway:
This works fine for database's created in SQL Server:
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Data Source=DESKTOP-ODUI05F\MSSQL2012;Initial Catalog=MyDatabase
but the same string generates the above error when connecting to the server/database created in VS.
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=aspnet-Widly-20160823125202
The server name is: (LocalDB)\MSSQLLocalDB.
The database is generated in VS using EF.
Please help - driving me nuts.
Thank you, Simon

Solved!
Followed the solution linked below.
Even though it's an MSSQL Server DB you're trying to connect to, using Excel Data Connection Wizard you have to ignore SQL Database connection option and choose "Other/Advanced" instead. I recorded it in a macro which produced all the vital parts for the connection string as follows:
How to connect to localDB in Excel
Provider=SQLNCLI11;
Integrated Security=SSPI;
Persist Security Info=False;
Data Source=(LocalDB)\MSSQLLocalDB;
Initial Catalog=aspnet-PTL-20160827031609
Besides doing the dishes this is my biggest and only achievement today! :)

Related

SSIS Active Directory Integrated

I am running some SSIS packages locally that need to insert data into an Azure v12 SQL Database. For authentication we would like to use "Active Directory Integrated". This works if I connect via SQL Management Studio so it is setup right. However my SSIS package is giving me an error of
My connection string looks like this
So note the authentication param which I think is causing the issue.
Any ideas onusing this type of security with SSIS? The SSIS package is being run from a SQL 2016 server.
SSIS OLE DB connections does not support Azure integrated security yet, and it's very undocumented. You have to workaround by creating an SQL login with password Or use ADO.NET connection
If you have an OLEDB connection using SQLNativeClient, you can make a change to allow the use of Active Directory. First download Microsoft® OLE DB Driver 18 for SQL Server®
https://www.microsoft.com/en-us/download/details.aspx?id=56730
Then view the SSIS package in code and change the connection string to 'Provider=MSOLEDBSQL;Authentication=ActiveDirectoryIntegrated;Encrypt=yes'
The UI will not display the AD options, but it will work for an Execute SQL Task, not yet managed to get it to work for and OLE DB source.
I also managed to get this working for an OLE DB data source by setting the DelayValidation True on the Data Flow.

Unable to create a new data source to SQL Server through ODBC

I'm new to SQL Server. I'm trying to create a new data source through ODBC Data Source Administrator for accessing a SQL Server database file (.mdf).
I first experienced an error msg
[TCP/IP Sockets]Specified SQL server not found
when running SQL Server ODBC Data Source Test.
After following all the steps in http://www.ceus-now.com/how-to-connect-to-ms-sql-express/, the previous error msg disappears and the tests are successful.
The connection seems to be successful. But then I experienced another problem is that, I could not choose the database. According to https://www.mssqltips.com/sqlservertip/1471/sql-server-dsn-and-odbc-configuration/ .
The problem might be "If using Windows security, you as the DSN creator, do not have rights to the database". Could someone help me solve this problem please? I really appreciate it! Thank you in advance!
I'm using Windows NT authentication. I'm using SQL Server 2014 (v12.0.2000). SQL Server connect to WORKSTATIONNAME/SQLEXPRESS.

ODBC DSN Connection Error - SQL Server 2014 Express Classic ASP

Trying to connect a classic asp page to sql server express 2014 using a dsn.
I've created a new database (in sql server management studio) called warehouse, with a table called users. I've added a new login called user1 with a password and mapped it to the warehouse database
I've created an ODBC System DSN on the same machine, using sql server native client 11 driver called SQLServer2 with integrated windows authentication, and a default database warehouse. Testing the connection at this point works fine!
On the ASP page I'm using:-
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "dsn=SQLServer2;uid=user1;pwd=xyz;"
Error:- Microsoft OLE DB Provider for ODBC Drivers error '80040e4d'
[Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot open
database "warehouse" requested by the login. The login failed.
I'm pretty sure that its a permissions issue and that the connection string is OK otherwise but after hours and hours of trying different strings, different users, I can't seem to get the damn thing to connect
If Anyone can throw any ideas my way I'd be very grateful. Thanks!
The way you are describing the problem the DSN uses integrated security so your credentials might be ignored and the database is called using the application pool identity.
If you have no specific reason why you need to use a DSN I would recommend using a connection string like the following:
objConn.Open "Provider=sqloledb;Server=yourdbserver;uid=user1;pwd=xyz;Database=warehouse"
A look into your SQL server log might give you a hint as to which user is actually failing to connect to your database.
I think you should have done something like this
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString "dsn=SQLServer2;uid=user1;pwd=xyz;"
objConn.open

Pulling data from Azure SQL database into an Excel through a parameterised stored procedure

I have data in an Azure SQL database, which I would like to pull into an Excel sheet through the use of stored procedure(s) which require parameters.
However, I'm struggling to do this, as I cannot get it to work how it works with a local SQL server. Ordinarily this is done through Microsoft Query, defining the connection to the database, and entering { CALL sproc (?) } and then using the Connections command to map a cell to the parameter.
I cannot set up a connection to the database in MS Query. When I enter the xxx.database.windows.net as the server, my username / password, and then try to switch to database I need to use I get the message below
Filling listbox failed:
SQLState: '37000'
SQL Server Error: 40511
[Microsoft][ODBC SQL Server Driver][SQL Server]Built-in function 'has_dbaccess' is not supported in this version of SQL Server.
Can anyone offer any assistance please?
Create a text file with the .DSN extension then add content like the following into it...
[ODBC]
DRIVER=SQL Server
SERVER=xxxxxxxx.database.windows.net,1234
APP=Microsoft Office 2010
WSID=NA
DATABASE=DB12345
[Microsoft Office]
UID=myUsername
PWD=myPassword
You can then just use this connection from Microsoft Query without dealing with the dialogs that are giving you grief.
I just figured this out with a combination of Youtube videos and dumb luck lol. You have to create an OBDC connection with Microsoft ODBC Driver 13.1 for SQL Server (or higher.) Make sure you connect and define the correct database in the ODBC object while entering in your Azure SQL connection info. Once that's done from within excel you can use MS Query to select that ODBC object and pull the data as you normally would.

Access Visual Studio 2008 server-based database from VB 6 project

Is it possible to access a Visual Studio 2008-created server-based database from a VB-6 application? If not, what is the best way to share a database between a VB-6 application and a C# application?
If you are referring to the SQL Server Express database that comes with Visual Studio 2008, you can access that with plain old ADO.
The connection strings for doing this are at http://connectionstrings.com/sql-server-2005. The most appropriate one is probably this one:
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;
Uid=myUsername;Pwd=myPassword;
For SQL Server Express (which is what comes with VS2008), don't miss the server name syntax Servername\SQLEXPRESS where you substitute Servername with the name of the computer where the SQL Server 2005 Express installation resides.
The reference for programming against a SQL Server database using ADO is here:
http://msdn.microsoft.com/en-us/library/aa905875(SQL.80).aspx
Example for connecting to the SQL Server database is below (untested). Note that this one uses SQL Server authentication rather than Windows Authentication. Check your connection strings on http://www.connectionstrings.com. If SQL Native Client doesn't work, try one of the others.
' Initialize variables.
Dim cn As New ADODB.Connection
Dim connectionString As String
' Specify the OLE DB provider.
cn.Provider = "{SQL Native Client}"
' Specify connection string on Open method.
connectionString = Server=myMachineName\SQLEXPRESS;Database=myDataBase; _
Uid=myUsername;Pwd=myPassword;
cn.Open connectionString
I just added a "Service-based database" to a project. I go the following in my app.config, in the configuratonStrings element:
<add name="SerializeToSql.Properties.Settings.Database1ConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
I don't know if ADO has user instance support. if it does, then you may be able to create
an equivalent connection string for ADO to use. Otherwise, you'll need to just create a "normal" database in SQL Server Express. You should be able to use that from ADO.
In order for other machines to see your SQL Express instance, you need to make sure it allows remote connections, the SQL Browser service is turned on, and is allowed through the firewall.
Fire up the SQL Server 2005 Surface Area Configuration tool: All Programs->Microsoft SQL Server 2005->Configuration Tools->SQL Server Surface Area Configuration.
Click Surface Area Configuration for Services and Connections
Click the 'Remote Connections' node and select 'Local and remote connections'. If you want to refer to the server as ServerName\MSSQLSERVER, you'll have to user named pips or TCP/IP and named pipes.
Click the SQL Server Browser node. Change the Startup type to Automatic and start the service.
For the firewall, make sure you make an exception for the SQL Server program (C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe) and for the SQL Server Browser program (c:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe)

Resources