Invalid Key for attachdbfilename - sql-server

I am using SQL Server DB. The connection string is
Data Source=office1\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dbSQLTest.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True
On local computer it is fine. On the network computer, it gives
"Invalid Key for attachdbfilename"
I do not want to make server client application. My purpose to use Sql server DB is to run my application on 3-4 computer simultaneously. I just make shortcut from my main computer to the network computers.
The reason why I donot attach with server instance is that it is difficult for the users to attach DBs with server and then manage SSMS.
Please advise
Thanks
Furqan

AttachDbFilename is used with local database. If you have remote database then the connection string will be different. Have a look at article - How to configure SQL Server 2005 to allow remote connections.

I'm not sure I am understanding you correctly, but you can't simultaneously attach the same MDF on a network drive by several concurrent users (like you can do with MS Access).
Rather just install SQL Express on a central computer and open it up for remote TCIP/IP access, and change the connection string to an IP / instance one.

Related

Cannot connect Access to SQL Server Linked Tables - error message loggingin

I have a client for which I am setting up a new SQL Server Express and (on a different computer) connecting their Access front end to that SQL Server. I created an account on SQL Server, changed authentication to SQL Server. I am able to log on to that account with no issues locally (through SQL Server Management Studio) on the server itself, but when I go back to the client machine and try to create either an ODBC connection or connect directly in Linked Table manager, I get the error below. Looking at the error log in SQL Server I can see no failed logins. In Access and/or ODBC I use Servername\SQLEXPRESS, choose SQL authentication and type in the username/password that I created. But it's still being stubborn.
I'm kind of at my wits end with this one. I checked to make sure that login is enabled, that the created database is mapped to this user, but I'm out of answers. Anyone have any ideas? I'm sure it's something really stupid that I'm overlooking, I've used SQL Server for a long time but I'm not an experienced DB Administrator I'm sure it's something really simple I'm overlooking, but I've done this hundreds of times before. And Windows Authentication won't work because it's on a different computer.
To connect to a named instance on SQL Server Express with Servername\SQLEXPRESS, you need:
SQL Server Browser service running,
and its UDP port 1434 open in the firewall.
https://learn.microsoft.com/en-us/sql/sql-server/install/configure-the-windows-firewall-to-allow-sql-server-access
SQL Server Browser service
UDP port 1434
The SQL Server Browser service listens for incoming connections to a named instance and provides the client the TCP port number that corresponds to that named instance.
The fixed TCP port for your instance open in the firewall.
You set this in SQL Server Configuration Manager
https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/configure-a-server-to-listen-on-a-specific-tcp-port
This looks more like a network setting rather than server issue.
Check if all necessary permissions, configuration and settings on your machine running the server are OK to accept external connections.
Usually its the server that is rejecting the connection for security reasons.

Connecting to SQL Database Server Remotely

I'll preface my question with: I am an absolute beginner with respects to the nature of MS SQL Server and have a layman's understanding of networking and 'computers' in general...
So, I'm trying to replicate an environment where:
There is an 'application server' which hosts HPE's ALM
This communicates with a database server with a Microsoft SQL Server DB
I currently have Microsoft SQL 2012 Server with a sample DB uploaded onto it on one laptop (Laptop 1) and the ALM software on the other laptop (Laptop 2). Both are connected to the same WiFi network.
Laptop 2 is asking me for Database parameters such as:
DB Host Name
DB Port Number (1433 by default)
OR Connection String
I have little idea of what I'm doing - I'd have thought it might be possible to connect to the DB through some sort of variant of the IP address of Laptop 1... but I'm unsure.
How can I connect to a MS SQL 2012 DB from one laptop to another? I realise this is probably a loaded question - I'd be happy if someone can point me in the right direction rather than an exact answer!
Thanks guys,
ST
I see two potential issues:
A corporate laptop might have firewall restrictions. So, you have to
open port 1433 for SQL Server.
Possibly you are playing with SQL Express, which by default, does not
have TCP/IP connection enabled. To enable it run "SQL Server
configuration manager", go to Network
configuration->Protocols->TCP/IP->Enable->restart SQL Server. Also check other properties. If static port 1433 is not set - set it.
Two types of adjustments must be set before connecting to the remote SQL Server. These settings are necessary because without them the connection to the remote SQL Server will not be able to be successfully created
Configuration settings:
-The SQL Server instance to allow the protocol being requested
-Allow access through the Window Firewall
1- Enabling TCP/IP protocol
2- Configuring Windows Firewall
For More details see the link :
https://www.sqlshack.com/how-to-connect-to-a-remote-sql-server/

running program in computers without sql server

Is it possible to run a program in which a SQL Server database has been used in other computers where "SQL Server" has not been install?
Certainly, you'd change the connection string to connect to a remote server like this:
Server=RemoteServerName;Database=DatabaseName;...
and in fact, that's the most common production configuration. A shared database amongst multiple users.
The answer is YES. The only thing you need to do is to point where the Microsoft SQL Server is placed. Of course, you need to configure the server to accept remote connections and that the client you're tring to connect has internet access.
Configure SQL Server to accept remote connections
Guessing that you use c#...
Connection strings for c#

how to connect ms sql database from one computer to the other?

I have a computer(computer A) which the ms sql installed, and I have another computer(Computer B) in which the application resides. I want to connect the ms sql database from computer B to computer using this application?How will I do that? What is the connection string should I use, firewall settings, database configutions, etc?
Well, firewall rules will have to open up port 1433 by default. That can change (but has little reason to), but if you're running just one instance and didn't change this, it's likely 1433.
Enable remote connections through sql studio and TCP/IP through connection manager:
http://forums.asp.net/t/1338911.aspx/1?how+to+enable+remote+Connection+sql+server+2008
And Joe Stefanelli's excellent connection strings site, www.connectionstrings.com; different application languages/tech will use different connection strings.
You'll also need a user of some sort, and whatever authtype. Easiest would be sql server auth, and that would be as easy as right clicking on the "security" folder under a database in management studio, and going new->user
Hope that helps!

connect sql server 2005/2008 over internet

How do I connect to SQL Server 2005/2008 using Management Studio or other desktop application over the internet?
Check out WCF Data Services:
http://msdn.microsoft.com/en-us/data/bb931106.aspx
That way, you don't have to totally expose your database server out to the internet, but you get fine grained control over what gets exposed and who (which type of user) can see or modify what.
Marc
I finally solved this by:
Changing default SQL Port to 8080 from 1433 (our ISP was blocking)
Turning off Windows Firewall on the server. I know this is not a long term solution, but at least I was able to pinpoint the problem. I had set two inbound firewall rules to allow port 8080 and SSMS program, on the server. I created an outbound firewall rule on the client for SSMS (but don't think this mad a difference).
I had to change all apps to use the new port instead of the default port. I had to configure our router to handle the new port 8080 and forward to the database server.
I will modify the Windows Firewall settings to see what was blocking SSMS.
DB Server: Windows 7 Pro 64bit 24 GB RAM
If you put 'your' SQL server (any brand, I'm not bashing) on the internet ... it won't be yours for long, unless you add some rather effective security measures ...
I suggest you look into VPN.
To be able to access your database over the internet, you will need to make sure that the server that hosts the database is accessible over the internet and the port that the database instance uses is open on that machine. You will also need to allow remote connections using the SQL Server Configuration Tool.
For Management Studio access I would recommend rather than opening the server to the outside to use a VPN solution that allows you to create a secure connection to the server and from there you can use the server name or IP to connect as if your machine is part of that network.
For the desktop application I would recommend looking into having the data be consumed through a web service or WCF rather than needing to have a direct connection to the database over the internet.
Hope this helps.
Firstly, if we put security consideration on the side, you have to configure SQL server (sql surface area configuration) to accept traffic, then you have to open proper ports on you server and allow inbound traffic thru to your router to the SQL server.
When you open sql server management studio in connect to server window and at the server name type the IP of your server and enter your username and password.
correct format : IP\InstanceName
you should have a user on target database.

Resources