Connection String to Connect to .MDF - connection-string

I've created a new project in VS2008, and added a .MDF file to the project. This is the first time I've tried to use the MDF files and .SQLEXPRESS databases (I've always used extenal Oracle servers in the past).
I'm trying to document everything as I go, but I can't figure out what credentials are being used to connect to the .MDF file. Is there an easy way to find out?

If you're using the *.mdf file in the App_Data folder of an ASP.NET app you can use this.
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;
If it's not an ASP.NET application don't use the DataDirectory syntax and just use the full c:\... path.

from where this name mydbfile ?
If you're using the *.mdf file in the App_Data folder of an ASP.NET app you can use this.
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|**mydbfile**.mdf;Database=dbname; Trusted_Connection=Yes;
If it's not an ASP.NET application don't use the DataDirectory syntax and just use the full c:... path.

For a local DB and no SQLEXPRESS server:
"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=""|DataDirectory|\MyDB.mdf"";Integrated Security=True;Connect Timeout=30"

Related

Is there any way to connect database with visual studio that connection string may not be changed at the time of deployment

When I connect I have already my localhost connection string. I want to know that is there any way that I connect database to visual studio but i don't have to change connection string all the time during deployment.
Simply you can use transform file to do this. In your Solution Explore expand your Web.config file then you will see there are 2 files as
Web.Debug.config
Web.Release.config
put your development configurations and connection string in Web.Debug.config and Deployment related configurations and connection string in to Web.Release.config
then it automatically pick the config file based on your build

In play framework I am unable to connect to sql server where windows authentication is enabled

I am trying to connect to SQL Server from play framework where my SQL Server is hosted on a different machine with Windows authentication enabled. I'm not sure how that can be done in play. I am new to the play work.
This is what I configured in my application.config:
db.default.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
db.default.url="jdbc:sqlserver://hostname"
db.default.trusted_connection="yes"
db.default.user="hari"
db.default.password="MyPassword"
db.default.host = "hostname"
db.default.logStatements=true
Any help on is appreciated.
There is nothing related to play frame work here , your need to have sqljdbc_auth dll file under your system32 folder and enable integrated security as true.
keep sqljdbc_auth.dll in your windows/system32 folder and it will work.Download sqljdbc driver from this link Unzip it and you will find sqljdbc_auth.dll.Now keep the sqljdbc_auth.dll inside system32 folder and run your program
along with the above changes I modified my application.config as follows
db.default.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
db.default.url="jdbc:sqlserver://hostname;databaseName=test;integratedSecurity=true"
db.default.trusted_connection="yes"
db.default.host = "hostname"
db.default.logStatements=true

PowerBuilder: DBMS DIR is not supported in your current installation

I am working on a migration project, where we are migrating one 32-bit PB12.0 application from Windows 2003 to 2012 server. We have copied all the required files and folders in the new server. Sybase Open Client has been installed and using ISQL we are able to connect to Sybase DB. We have not change anything in the PB12.0 code we just copied the .exe and referenced DLL in the new server.
While executing the job we are getting
DBMS DIR is not supported in your current installation
But if we navigate to the PB folder we can see PBDIR120.DLL is there.
Try to set a path variable to the directory. I had some simmilar issues ( with PB12.6 ) and this helped.
Finally the issue got resolved. The reason of the issue,
Previously, PB12.0 job was using Sybase Open Client OCS_12_5. As part of windows migration, Sybase Open Client is upgraded to OCS_15_0. Because of this there was a conflict between PBDIR120.DLL and the dlls under "OCS_15_0/dll" folder.
If we add the DLLs in the path from "OCS_12_5/dll" folder then the application is working fine.

PHPStorm: How to use a local mdb Access file with Microsoft Access Driver

Can't seem to find an option in PHPStorm Database to use an .mdb file, is there a plugin or other solution ? Or is possible to make the mdb file accessible by IP:PORT and then have PHPStorm use something compatible to connect ?
Thank you.

SQL server name in hosts file

I'm developing an ASP.NET application and we're using TFS for source control. Each time we need to change the "data source" in the connectionString to point to our local server during the development. I'm running SQLEXPRESS so I was writing .\SQLEXPRESS in the web.config file and it was working fine. Now we shouldn't modify the web.config file any more and will need to add a record into the hosts file to point the "data source" from the web.config file to my local machine's SQL server. Say, we have "DEVDATABASE" in the web.config as "data source", how should the hosts file line look like for that to work? Something like the following?
.\SQLEXPRESS DEVDATABASE
This however does not work. Could anybody please help me to understand what's the way it should work?
Thanks.
You can't use the hosts file (or DNS) to point at a named instance. This is meant to redirect only to a specific machine, not to a specific machine + port number. You could try creating an alias in the client network utility - you'll also want to make sure that TCP/IP is enabled and that the SQL Browser service is running.

Resources