I want to do system to control other machines in LAN. I need here a database, but it should be one database for all computers. I hope it's possible to have installed SQL Server only on chosen machine and connect from others to him over LAN?
Or make db on each comp and synchronise fom time to time with main db?
YES OF COURSE!!
That's the whole point of a database server....
You install a SQL Server version on your server machine, and any number of clients in your LAN can connect to it, read data from it, store data on it.....
Since you're in a LAN environment (inside a company), I would recommend using Windows authentication (the user names people are logged into Windows with) as your security mechanism. You can easily configure certain Windows users (or Windows groups) to have access to your SQL Server (and others are locked out).
Once you have set up your database server, your client apps can connect to it using a connection string something like this:
server=(server-name);database=(your database name);integrated Security=SSPI;
Related
Please forgive me if the title is not correct. I am still trying to understand how this works.
I have installed MySQL workbench and the MySQL server on my laptop. I have successfully created a database that store driver details, as per the picture.
I can access this info only one my laptop. However, I would also like to access this info from other PC's. I was thinking of having the main database in a secured room and then connecting about 3 additional PCs to the main database.
I have also written a simple c# script on Visual Studio that runs on my main laptop where the database is stored. This script just allows a user to enter his username and password and then displays the contains of the database (the table in the database) on a datagrid view. I have included the SQL injection code to prevent unwanted characters. This application also allows the user to insert, update, and delete info from the database provided the user that logs in has these privileges granted.
Now I would also like to run this application on the other 3 PC's, but obviously I have a problem. This problem is these PC's cannot access the main database. The main database user has privileges that allow him to alter the database but the other uses that are located in the access points to do not have this privilege. All they can do it enter their username and password and see the data from the database been displayed on the datagrid view.
So my question is how do I grant access to these other three PC's to access the main database?
MySQL Workbench and MySQL server is so far only installed on my laptop and not on the other 3 PC's.
Database users
Error message
The entire point of database technology is to allow multiple clients to access the same server and share the same data. (Actually there's another point: the ability to handle vast amounts of data. But that's not your problem right now.)
Here's what you need to do.
Get MySQL server software set up on a server in your server room. Find out the hostname of that server.
Log in to that server using MySQL Workbench. It asks you for the hostname.
Use Workbench to migrate your data from your localhost MySQL server to the one in the server room. Workbench has decent features to help you do that.
Create a mysql account on the shared server that just has access to the database you just created. Keep in mind that MySQL users look like this: 'david'#'localhost' or 'david'#'*' or 'mickey'#'*.animation.disney.com'. That is, they specify both the username and the machine the user runs on.
Change your C# connection string to mention the shared server's hostname and the account you just created.
myConnectionString = "server=shared.example.com;uid=root;pwd=12345;database=test";
Somehow tell the other users of your app to use this connection string.
There's another, simpler but less robust, way to do all this. Make sure your laptop has its own hostname. I dunno, david.example.com maybe? Ask your local LAN or VPN administrator. Or just use your laptop's IP address in place of a hostname. Then put that hostname into your connection string. Then other users of your application can hit the MySQL server on your laptop. But, if you switch off your laptop and take it home they'll lose access.
I am looking into using the new SQL Server Express LocalDB (I think it is code named "Denali") for a desktop application.
It is currently running with SQL Compact, but the user is wanting to share the database between multiple PCs on a network. Unfortunately this is not something that SQL Compact can do, so I am investigating other solutions.
The client requires the ability to send database files easily to other sites or to back them up to a flash disk, so I am avoiding going to SQL Express because there is quite a bit of "administrator" knowledge required to backup and restore.
So, my questions is, does the new SQL Express LocalDB support remote connections to the database over a network and/or through a shared network folder with the mdf file in it?
LocalDB does support supplying a path for an attached local DB in it's connect string (AttachDbFileName) hence the shared network folder option.
NOTE: This question pertains to "LocalDB" the new version of SQL Express 'Denali' and not to SQL Server Express 2008 or prior.
See article here announcing LocalDB's release: http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx
No, SQL Server Express LocalDB doesn't accept remote connections.
The idea with shared network folder might work, but only if you are able to make sure the LocalDB instance is shutdown before you try to copy the file. Also keep in mind that only one LocalDB instance can have any given database file open at the same time. and don't forget about the log files!
Additional security warning: unlike SQL Server Compact databases, SQL Server Express databases (including LocalDB ones) are not designed as secure data exchange format. For instance, they can contain malicious code in .NET assemblies embedded in them. So you should never open databases from untrusted source.
Maybe providing the customer with a simple tool that automates the backup process would be a better idea?
This isn't a fresh thread, but I would like to share my experience with SQL Server Express database LocalDB.
I have a WPF C# project using SQL database with LocalDb Engine. It is working fine no problem, I can use the database with the WPF app. I wanted this app to work on network with more PCs.
On the network another PC can use the database from my PC using UNC path in the connection string.
It seemed to me the remote connection is working. However when the remote PC is connected, I am not able to use the database with my local WPF app. If I run my app first the remote PC could not connect. So this tells me that the remote connection is working, but the multiple connection is not allowed.
OK, I didn't give up and I run the app from my PC twice and I saw it is working which tells me that the same SQL LocalDB engine can handle multiple connections locally only.
I hope this experience will help someone. Thanks.
In short, yes it can. Here is a tutorial on how to configure it.
Also, here is another post with a potential issue that might occur.
Both explain how to configure SQL Server Express to accept Remote Connections.
I am developing a C# Windows Forms app for event management. There will be 15 gates with RFID readers. These readers will read the UID and query the database to check if it is unique entry for that day.
Now if for some reason, SQL Server is not available, I want the app to store the data in a local database and sync as soon as the connectivity is restored.
Any idea on how should I do it?
Thanks
You could use SQL Server replication, and install SQL Server Express with a local copy of the database on each device.
I want to create a windows application in C# and SQL Server, these have two databases one is in local another one in remote. I have 2 doubts:
Is possible to connect remote SQL Server in windows application?
Some time Internet may be not available (may be chance). This time I cannot fetch and store data in remote server, my application not running that time,how can avoid this situation?
Full data available remote server, partial database only in local SQL Server
please share ideas to me.
is possible to connect remote sql server in windows application?
Yes. Provided if remote connection in SQL Server is enabled. See How to enable remote connections in SQL
Some time Internet may be not available (may be chance).This time I
cannot fetch and store data in remote server , my application not
running that time,how can avoid this situation?
Check for connection to your server or catch exception to see if server is unavailable. Write the data on your local server or local XML file and then implement sync logic when ever your server becomes available
I am pretty new to SQL and I'm stuck on something which is probably a few clicks away.
The program I am building will store the data in the database created on the management studio. Everything works fine on a test application. Now the question is: how should I connect to the database if I want to open the program from another computer? I tried copying the test project on a friend's computer but it cannot find the database as I suppose is obvious because the db is stored on my pc.
i know hundreds of questions like this exist around google but I'm sick of looking at forums reading complicated stuff. any help will be really appreciated.
thanks.
In the database connection settings or script you propably have database server set to 'localhost'
Try setting this to the computer network IP if the other computer is inside the same network.
To connect to it from outside the network (over the internet) You need set the database server setting to you external IP and you have to port-forward (NAT) the SQL server port to your computer.
If you can tell us what database software you are using for the Database I can tell you what port to forward, for more help with forwarding you should ask on serverfault.com and also provide your router/firwall make and model
It depends (at least partly) on how you're connecting to the database in the first place. Normally, you'll have some sort of connection string that tells what computer to connect to. It'll be set to the local computer by default, but changing it to something else is normally just a matter of editing that machine name into the string.
If you're connecting via ODBC, the program will just specify an ODBC connection, and the ODBC connection will specify the machine to connect to. You can use the "Data Sources (ODBC)" control panel to edit these (depending on the version of Windows you're using, it may be in the "Administrative Tools" folder instead of showing up directly in the control panel).
when you want to connect to a sql server over the network there are a few things you should know/check:
is your connection string correct (not localhost)
does the remote sql server accept tcp/ip connections
does the firewall of the remote compture allow the connection
Is the sqlbrowser running on the remote computer (if not you need to specify the port in your connection string.
To make sure this al works the best thing you can do is try to connect from the new pc to the remote database using sql management studio or if you don't want to install the ssms you can try to create an odbc profile that connects to the remote pc. By doing this you can determine if the problem is with the database itself or with your application.