Why can I not connect to SqlLocalDB? - localdb

I craete and start a SqlLocalDB-Instance with
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SqlLocalDB.exe c proconact -s
when I run
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SqlLocalDB.exe info proconact
I get
Name: proconact
Version: 11.0.3000.0
Shared name: proconact
Owner: SUNNY-AME\sunny
Auto-create: No
State: Running
Last sttart time: 09.03.2017 16:40:30
Instance pipe name: np:\\.\pipe\LOCALDB#SH2D214E\tsql\query
When I try to connect with
"C:\Program Files\Microsoft SQL Server\110\Tools\Binn\Sqlcmd.exe" -S (LocalDB)\.\proconact -E
or
"C:\Program Files\Microsoft SQL Server\110\Tools\Binn\Sqlcmd.exe" -S (LocalDB)\proconact -E
I always get the following error:
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Named Pipes Provider: Could not open a connection to SQL Server [2]. .
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or instance-specific error has occurred while establishing a connection to
SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For
more information see SQL Server Books Online..
I hope someone can help me, what I can do.

You need to use:
-S "(LocalDB)\proconact" -E

Related

.NET 5 Connecting to MS Access mdb with Odbc

I am trying to connect my web application to an old MS Access mdb file.
I found this page:
https://learn.microsoft.com/en-us/dotnet/api/system.data.odbc.odbcconnection?view=dotnet-plat-ext-6.0
But I can't figure out how to work with connection strings, I keep getting the Error:
'ERROR [08001] [Microsoft][ODBC Driver 18 for SQL Server]MAX_PROVS: Error Locating Server/Instance Specified [xFFFFFFFF].
ERROR [HYT00] [Microsoft][ODBC Driver 18 for SQL Server]Login timeout expired
ERROR [01S00] [Microsoft][ODBC Driver 18 for SQL Server]Invalid connection string attribute
ERROR [08001] [Microsoft][ODBC Driver 18 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.'
https://www.connectionstrings.com/microsoft-odbc-driver-17-for-sql-server/
Found this page, although I have the 18 driver installed it should only change the 17 -> 18.
My current Connection string looks like this
Driver={ODBC Driver 18 for SQL Server}; Server=.\SQLExpress; AttachDbFilename = D:\temp\datacollector\microfas.mdb; Trusted_Connection=yes;
But I have no idea if I am approaching it the right way. The application will eventually run locally at a customer with a known location of the .mdb file.

Entity framework with db mode cannot connect to server

I am trying to connect to by db instance using db first, I created a connection
<add name="Entities"
connectionString="metadata=res://*/Models.ModelCmarket.csdl|res://*/Models.ModelCmarket.ssdl|res://*/Models.ModelCmarket.msl;provider=System.Data.SqlClient;provider connection string="data source=(localdb)\v12.0;initial catalog=Cevaheer;integrated security=True;trustservercertificate=False;multisubnetfailover=True;MultipleActiveResultSets=True;multipleactiveresultsets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
And I always get an error -
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. The specified LocalDB instance does not exist.)
But if i try
<add name="CevhermarketEntities"
connectionString="Data source=(localdb)\v12.0;initial catalog=Cevaheer;integrated security=True;trustservercertificate=False;multisubnetfailover=True;MultipleActiveResultSets=True;user id=dbuser;password=flexsin#123!;multipleactiveresultsets=True;"
providerName="System.Data.SqlClient" />
I can connect, and also can connect from VS sql server explorer and SSMS.
To begin - there are 4 issues that could be causing the common LocalDb SqlExpress Sql Server connectivity errors SQL Network Interfaces, error: 50 - Local Database Runtime error occurred, before you begin you need to rename the v11 or v12 to (localdb)\mssqllocaldb
You dont have the services running
You don't have the firelwall ports here
configured
Your install has and issue/corrupt (the steps below help give you a nice clean start)
You did not rename the V11 or 12 to mssqllocaldb
I found that the simplest is to do the below - I have attached the pics and steps for help.
First verify which instance you have installed, you can do this by checking the registry and by running cmd
cmd> Sqllocaldb.exe i
cmd> Sqllocaldb.exe s "whicheverVersionYouWantFromListBefore"
if this step fails, you can delete with option d cmd> Sqllocaldb.exe d "someDb"
cmd> Sqllocaldb.exe c "createSomeNewDbIfyouWantDb" create - the pic is error
cmd> Sqllocaldb.exe start "createSomeNewDbIfyouWantDb"

Windows client error for DB2 10.5 fp3 DATA BASE Connection refused:Error:SQL30081N and SQLSTATE IS 08001

When we connect to database we got error in windows client machine.
Error:SQL30081N and SQLSTATE IS 08001.
SERVER:HP-UX DB2 10.5 FP3
Please suggest on this.
A quick Google suggests this may be the result of a firewall blocking the connection: http://www-01.ibm.com/support/docview.wss?uid=swg21503305

OBDC and ExecuteReader issues

I'm trying to do a little powerShell script, which establishes a OBDC connection using SQL Server Native Client 11.0 as Driver and retrieve some data which, in my case, is just getting the list to the database tables.
##### Start the database connection and set up environment
$DbString="Driver=SQL Server Native Client 11.0;Server=[server_name];Database=[db_name];Uid=[user];Pwd=admin#[pwd];Encrypt=yes;Connection Timeout=30;"
$DBConnection=New-Object System.Data.Odbc.OdbcConnection
$DBCommand=New-Object System.Data.Odbc.OdbcCommand
$DBConnection.ConnectionString=$DbString
$DBConnection.Open()
$DBCommand.Connection=$DBConnection
$sqlQuery = "show tables;"
$DBCommand.CommandText = $sqlQuery
$DBCommand.ExecuterReader() //Crashes
The problem is when I run it, I get this problem
ERROR [42000] [Microsoft][SQL Server Native Client 11.0][SQL Server] Could not find stored procedure 'show'
It seems like the problem comes from ExecuteReader but I can't find a way out, please help !

SQL Server 2008 R2 - Unable to rebuild master database, Cannot shutdown service

Yesterday I noticed I could not execute any query within the master database. I tried a DBCC CHECKDB but this just hung (let it run for 24 hours). I was unable to stop the SQL Server service: "The service cannot accept control messages at this time"
I decided to try to rebuild the master database: setup /ACTION=REBUILDDATABASE /QUIET /INSTANCENAME=MYINSTANCE /SQLSYSADMINACCOUNTS=MYACCOUNT /SAPWD=MYPASSWORD
Summary.txt seems to indicate the same problem:
Detailed results:
Feature: Database Engine Services
Status: Failed: see logs for details
MSI status: Passed
Configuration status: Failed: see details below
Configuration error code: 0x0A2FBD17#1211#1
Configuration error description: The service cannot accept control messages at this time.
Configuration log: C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20140517_091501\Detail.txt
It looks like the SQL Server cannot be shutdown. What can I do about this?
"SHUTDOWN WITH NOWAIT" looks to have fixed the problem.