https://blog.jetbrains.com/datagrip/2016/10/07/connecting-datagrip-to-sql-server-express-localdb/
The description above worked fine. But the opened DB contains system tables like spt_monitor, spt_fallback_dev. (sqllocaldb.exe i showed only one localdb)
I have an mdf file which contains the DB I want to use. Any idea? (I tried to give the full name of the mdf file in the uppermost Database field, but it did not help)
One more info: In visual studio sql server object explorer, I see the system databases and the mdf files as well. In vs / server explorer I can connect to the mdf file.
I found the solution:
after giving username and password go to schema tab
(exit from visual studio)
check the mdf file, check the relevent schema, e.g. dbo
if you missed this step then database double click on "connection / schemas" to make the check
Related
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?
Basically I want to attach .mdf file which located in D(you can see it from the picture), But then I got this error.
Any idea why this happened and how to fix it?
There may be two solutions for that
1) You may start the sql server management studio application by right clicking and selecting the "Run as administrator" to run it and then try to attach the database in D:
1) You may put your database in the default directory of your database like C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA etc ....
enviroment
visualStudio 2012
localdb v11
a solution with 3 projects on it:
1st class library with an ORM database model, and a local db Localdb.mdf inside App_Data directory.
2nd is a web project that uses this database model.
and 3rd a c# console project that uses this localdb database, referencing the 1st class library, and having at the app.config a localdb connection string defined as:
Data Source=(LocalDB)\v11.0;AttachDbFilename=C:_work_desarrollo\Apps\Business\OpenAccessAppsModel\App_Data\LocalDb.mdf;Integrated Security=True
My problems are:
i would like to made some changes using VS 2012 server explorer to this database like deleting tables and i got "The database is readonly. Updates to the database will not succeed until the database is made read write"
and second, how can i made available to the console application (the 3rd project) the database file so i can copy/paste the release folder to "install" the console application?
How the database connection should be modified to have the database locally with the console applciation? (same directory as the app)
Thanks a lot
Happened to me today.
You can grant/change db permissions like this:
icacls mydabase*.* /grant "NT Service\MSSQL$SQLEXPRESS":(F)
icacls mydabase*.* /grant "MYMACHINENAME\Administrator":(F)
I already had sqlexpress permissions set but found out that machine\administrator was also needed.
Hope it helps.
Please check atribute of .mdf and .ldf files and the container folder.
Check this answer as well.
I've done these two things and Presto! It Works!
The problem is only file .mdf and .log permissions over the user or application execution. Only give the security permission read and write in the file properties and the connection string for example "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\WinApps17\Cash\Invoices\Data\VFindx.mdf;Integrated Security=True;Connect Timeout=30"
How can i rename the database in sql Azure?
I have tried Alter database old_name {MODIFY NAME = new_name} but not worked.
Is this feature available in SQL Azure or not?
Just so people don't have to search through the comments to find this... Use:
ALTER DATABASE [dbname] MODIFY NAME = [newdbname]
(Make sure you include the square brackets around both database names.)
Please check that you've connected to master database and you not trying to rename system database.
Please find more info here: https://msdn.microsoft.com/en-US/library/ms345378.aspx
You can also connect with SQL Server Management Studio and rename it in Object Explorer. I just did so and the Azure Portal reflected the change immediately.
Do this by clicking on the database name (as the rename option from the dropdown will be greyed out)
Connect with SQL Server Management Studio to your Azure database server, right-click on the master database and select 'New Query'. In the New Query window that will open type ALTER DATABASE [dbname] MODIFY NAME = [newdbname].
It's Very simple for now - Connect to DB via SQL Management Studio and Just rename as you generally doing for DB [Press F2 on DB name]. It will allow you to do this and it will immediately reflect the same.
I can confirm the
ALTER DATABASE [oldname] MODIFY NAME = [newname];
works without connecting to master first BUT if you are renaming a restored Azure database; don't miss the space before the final hyphen
ALTER DATABASE [oldname_2017-04-23T09 -17Z] MODIFY NAME = [newname];
And be prepared for a confusing error message in the Visual Studio 2017 Message window when executing the ALTER command
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
You can easily do it from SQL Server Management Studio, Even from the community edition.
I have a few database servers and few developers.
I have set up database connection definitions on my PC for each servers and now I want to share with other developers but I was not sure how to export and import the definitions.
I am running pgAdmin 1.10.2 on Ubuntu 10.04 (lucid).
You should have a .pgadmin3 conf file in your home directory. You just need to give that one to your fellow developers.
By the way, for those looking for the answer to this question on the Windows platform, the server definitions are stored in the Windows registry at HKEY_CURRENT_USER\Software\pgAdmin III\Servers
You can export this key to a .reg file and share it. However, due to the naming of the keys, it will likely overwrite any existing keys in the target registry.
On Original Computer
Export the server definitions found in Windows registry found here:
Windows Key > regedit
HKEY_CURRENT_USER\Software\pgAdmin III\Servers
Right Click on Servers Folder and click Export
Leave the default radio button 'Selected Branch' the way it is. This will be how it knows where to insert it when you want to import it.
Choose a name for your file (e.g. pgadminServers) and click Save
This is the file you will use to import to another computer (which ideally has the same version of pgAdmin)
On New Computer
Make sure pgadmin is not currently open
Windows Key > regedit
File > Import > Choose your pgadminServers.reg file.
Click Ok to the alert that says 'The keys and values contained in //filepath have been successfully added to the registry.'
Close or exit the registry editor
Launch pgAdmin
PgAdmin 4 stores the server connection details in an SQLite3 file.
In Windows this file is located at:
%APPDATA%\pgAdmin\pgadmin4.db
In Linux it lives at:
/var/lib/pgadmin4/pgadmin4.db
You can configure a custom location by editing
config_local.py file.
Not enough reputation, else I would add a comment to #ojhurst
IF you leave your pgAdmin III open or have already added a server and then import the pgadminServers.reg file
Edit that file (or modify entry in registry) the following entry
[HKEY_USERS\S-1-5-21-....-1140347\Software\pgAdmin III\Servers]
"Count"=dword:0000001
to the total count of servers (e.g. 53)
[HKEY_USERS\S-1-5-21-....-1140347\Software\pgAdmin III\Servers]
"Count"=dword:0000053