Why is the instance piped name empty in my LocalDB configuration? - localdb

I wanted to connect to my LocalDB through jTDS. In the connection string the Data Source is (LocalDB)\MSSQLLocalDB. I discovered that I need the instance piped name to connect to the db, so I ran sqllocaldb i mssqllocaldb but the instance piped name is empty.
What can I do to connect?

The instance piped name was empty simply because is was not running, I went in visual studio and then it showed me the piped name

Related

Postgresql 9.3 ignores pgpass.conf file

Using Windows 10 and PostgreSQL 9.3.
I have a batch file that executes a series of pg_dump commands to back up selected tables in a database, and a related file that uses psql to restore them into an empty database. For every call to pg_dump or psql, I have to enter a password. On customer's machines (usually some version of Windows Server), I have a pgpass.conf file to specify the password, and I don't have to enter it every time.
My pgpass.conf file contains localhost:5432:*:someuser:somepassword. I have tried putting it in %APPDATA%/postresql and putting it into a folder named c:\misc and creating an environment variable named PGPASSFILE containing c:\misc\pgpass.conf. I restarted the PostgreSQL service after I changed each one.
What am I missing?
I am afraid this is sort of a non-answer.
I figured I should try with a supported version of PostgreSQL, so I installed 9.6. I assigned it port 5435. I added a corresponding line to the file pointed to by my PGPASSFILE environment variable. It worked. I tried targeting my 9.3 database. It still worked. I removed the line for port 5435. It still worked. I copied the pgpass.conf file into the default %appdata%/postgresql folder, deleted the PGPASSFILE and it still worked!
So, I have no idea what was broken, nor do I have any idea what fixed it, but it's fixed.

localdb does not create database file if its missing

I use this connection-string:
Server=(localdb)\\MyInstance;Timeout=30;Database=MyDB;AttachDBFilename="C:\Temp\MyDB.mdf";Trusted_Connection=True;
Once I run a migration from my code using
dbContext.Database.Migrate();
Normally, this "simply" works. The db is not just migrated, it is also getting its file created for it.
However, on the device of a colleague, the same code results in this error message:
System.Data.SqlClient.SqlException: "Cannot attach the file 'C:\Temp\MyDB.mdf' as database 'MyDB'."
If I give my database files to my colleague and he places them in the appropiate directory first, everything works as expected and the other code in that program can access everything in it, as it would do normally.
We've tried different paths and always checked the file-system rights. LocalDB or entity-framework (I'm not sure which is normally responsible for creating database files) simply won't create the database-file if it's missing on his device.
Are there any switches causing this? Can I explicitly tell localdb with the connection-string that it should create the database file?

EF7: error connecting to a local db database

I'm trying to create a new asp.net core app which uses EF7 to access a local db database and I'm having some problems with the connection string. I've installed the local db service and I have already created several instances:
PS C:\Users\luisabreu> sqllocaldb info
MSSQLLocalDB
ProjectsV12
ProjectsV13
v11.0
MSSQLLocalDB is running v12:
PS C:\Users\luisabreu> sqllocaldb info mssqllocaldb
Name: MSSQLLocalDB
Version: 12.0.2000.8
Shared name:
Owner: GRM\luisabreu
Auto-create: Yes
State: Running
Last start time: 05/04/2016 08:46:17
Instance pipe name: np:\\.\pipe\LOCALDB#518FD662\tsql\query
This is the connection string I'm passing to EF:
{
"usersCnnString": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=UsersInfo;Integrated Security=True"
}
Btw, I've already tried this one too:
"usersCnnString": "Server=(localdb)\\mssqllocaldb;Database=UsersInfo;Trusted_Connection=True"
And here's the setup code I'm using for setting up ED dependencies:
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<UsersContext>(options => options.UseSqlServer(Configuration["usersCnnString"]));
Whenever I try to access the database,I end up with the following error:
System.Data.SqlClient.SqlException (0x80131904): 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. Specified LocalDB instance name is invalid.)
I'm surely doing something wrong, but what?
thanks!
Luis
Well, it was something simpler...don't forget to kill iis express whenever you change the config of an ASP.NET Core app so that you'll get the correct config data when you re-run the app. The problem was that when I pasted the path:
Server=(localdb)\\mssqllocaldb...
into the json file, VS 2015 automatically escaped the string, turning it into:
Server=(localdb)\\\\mssqllocaldb...
Yes, I've noticed it, but only after trying to load the app on the browser. I corrected the path but didn't kill the IIS Express instance I was using to test my app. So, the error message was absolutely correct because it was still using the old path (which was trying to reach the mssqllocaldb instance running on a localdb server).
Again, stupid error. Hoping that my mistake will save someone else's 30 mins in the future...
if I create a project with user accounts using VS 2015 with RC1 the project template generates the connection string like this:
{
"Server=(localdb)\\mssqllocaldb;Database=thedbnamehere;Trusted_Connection=True;MultipleActiveResultSets=true"
}
I would try making it closer to that, but also wondering if for some reason UsersInfo might not be a valid name, could be some keyword clash
I noticed that vs uses the "userSecretsId" from project.json as the dbname, not sure if that is required but might be worth trying

Error restoring database on new SQL server instance

I am trying to restore a database backup on a newly installed named instance on SQL Server 2008 R2. I have several other named instances on the same server and have no problems restoring database backups but when I try the restore on the new instance I get as far as the "Specify Backup" dialog and click the "Add" button and instead of getting the "Locate Backup File" dialog I get the following error ...
Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.ConnectionInfo)
Column name or number of supplied values does not match table definition. (.Net SqlClient Data Provider)
Server Name: localhost\DEVSERVER1
Error Number: 213
Severity: 16
State: 7
Procedure: xp_fixeddrives
Line Number: 1
I installed SP2 for the instance and rebooted the server but I still get the above issue. A named instance that restores fine and the new named instance with errors are showing the same version in SQL Server Mgmt Studio 10.50.4000.
I am starting SQL Server Mgmt Studio as Administrator. Still no joy.
Any ideas?

How to access the database imported through datapump

I just imported data dump through below command:
IMPDP user/pass FULL=Y DUMPFILE=BIRDV24012014.DMP LOGFILE=BIRDV24012014.log;
The dump has been restored the issue is i dont know how to connect to this database that i just imported, what service or TNS does it resides and how can i query it?
You didn't import a database, you imported the contents of your file into your existing database. If you could successfully run impdp user/pass then your ORACLE_SID etc. is already set and you should be able to log in and query with sqlplus user/pass.
If you've come from another RDBMS background you may be confusing 'database' with 'schema'. Depending on what was in the dump, you've probably created a load of schema objects and data under the USER schema or whatever your real 'user' value was).
The import makes no difference to this, but if you want to access the database from another client (e.g. from another machine, or over JDBC) then you'll need to check your listener configuration to get the hostname/IP address and port it's listening on, and get the service name for the database; all of which can be obtained from lsnrctl services if you have permission to run that. You can then use those values for a JDBC URL, or in a tnsnames.ora entry, or ODBC, etc.
Look at your ORACLE_SID environment variable. There you'll find the instance ID. If you ran the IMPDP tool as user Oracle, you should also be able to connect to the database using
sqlplus / as sysdba
If all fails, look at your /etc/oratab file to see which instances are available on this host.
On another note, your command seems incomplete. Datapump requires a DIRECTORYparameter to know where to look for the dumpfile you specified.