I have built a SQL database program that holds part numbers and details about them. Right now the program works locally on my machine. However, what I need to do is have the program access the database on a network drive (eg. the L:\ drive). This way, a user can have their own copy of the program, but all the data that is sent and received is done to that common networked database. I have been playing around and also searching online, but cannot seem to find anything, and I am a database beginner. Any help would be much appreciated. Thanks.
What you want to do is install a sql server instance somewhere on your network. Then use a connection string rather than a drive location to access the data.
This is the standard way to share data across applications.
THe problem with this approach is locking and multiuser support to put it simply. You will run into users contending for access to the file . You need a DB server ( SQL Server , Sql Server Express, MySQL , etc etc) to handle this problem for you . The DB server can running on that network server .
Related
In my application I need to use a local database (the application I'm creating works with everything locally). I had one database that worked really bad, because sometimes it saved the data and other times don't. And if I published the program I couldn't find the database file.
But I am having some trouble to know where to place the database. I have created one in E:\PAP\Trabalhos\Trabalhos\database.mdf and other in E:\PAP\Trabalhos\Trabalhos\bin\Debug\database.mdf, but in any of those paths the database is recreated/goes back to the previous state, when I try to start the program.
In my connection string I have this:
Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|database.mdf; Integrated Security=True
and that points to the file ...\bin\debug\database.mdf
I want to be able to access the database in any computer I use the program and be able to actually save data.
Where is the recommended path to place the database file and be able to access it independent of the computer I am using?
Should I use Windows authentication or SQL Server authentication?
tl/dr: Database doesn't save data and I want to be able to access it in any computer without any extra steps.
You can't use "(LocalDB)\" and access it from any computer. LocalDB is by design accessible only from the applications running on the same computer (it is an embedded database).
To access database over the network you need to install instance of SQL Server, like full SQL Server Express instance or use some cloud service like AWS or Azure.
My application should do backup of SQL Server 2008 R2 data. It works fine when app is on server. When I get app to client PC and connect to Server, server cannot find path...
So I decide to use VDI for Backup, find this page http://www.codeproject.com/Articles/19449/Accessing-the-SQL-Server-Virtual-Device-Interface and after some changes, it works fine on local PC. But when I try to backup on server-client. I cant make VirtualDevice on server.
It looks like I need to set VDI server address to create VirtualDevice on server. After that I will be able to use stream to server.
Does anyone have solution? That c++ code is strange to me.
Or if there is another possibility how to make C# app backup database on remote server without using sharedFolder?
Thanks, Jakub
No matter where your drive is or what your drive is [Virtual/Physical] where you want to take a backup. As long as it is shared you will be able to take a backup there.
Say you have a ClientPC and You have shared a folder P:\Backup. Now when taking backup you will use the UNC path something like this....
BACKUP DATABASE [Test_DB]
TO DISK = N'\\ClientPC\Backup\BackupFile.bak'
This question is about VDI (virtual device interface) which is a way to stream the backups to his software - i.e. it won't use a network share nor a local file - it will stream to his code instead.
I do know you need to be in the sysadmin role to run VDI, however I'm not sure of more information about the exact requirements - I was curious about if something could be done via VDI and ran across this post in researching it.
Good luck..
I created a C# application that uses .mdf database and it works perfectly on my PC.
Now i wanted to install that application on network PCs that can connect to a single database and use that data.
I tried changing the connection string in application with only changing file path, but it doesn't work. How can i use one PC as server and use program as client application that can connect over network. How do i set up SQL server on that PC, and should i do that? How is this done? I couldn't find any tutorial so far...
Could someone help me a bit.
I don't think you should be doing this, this is something that I once looked into myself. I once used a standard base unit for this same purpose and although it worked fine your not really supposed to do it.
You have to ask yourself how important the application is to the business. If its critical then this would be a real bad move for a couple of reasons :-
1) What happens if base unit hosting SQL Server dies? or is switched
off. Your unstuck.
2) You will only be able to schedule backups of the
SQL Server Database on the local hard disk . If the Disk dies then you
will lose everything.
When all is said and done, for the scenario that you are presenting, a MS Access database is probably a cleaner way to go. Access databases, albeit dated, can be hosted on a shared network space and can be accessed by multiple users. ADO.NET is nt too bad and you can still use LINQ with Data Tables etc.
What your looking into doing in your description wont really be fruitful unless your hosting the SQL Server on an Actual Server, as its designed for.
Some people suggest using using SQL Compact, but that itself is designed only to run from a local machine.
Hope this Helps.
#Milan: Go to the SQL Server configuration manager and enable TCP/IP service for SQL Server. As sql server uses TCP/IP for communication.
This link will help you.
http://kristofmattei.be/2010/06/21/enabling-sql-server-2008-r2-access-over-network/
I'm a newbie.. So, please forgive me if it's a simple question :)
I'm developing a system to get some specific data and store it to a database using C#. I have almost finished the system.
I'm using a MySql database running locally on my machine. I need this database to be accessed remotely so that my employer can view the data. He told me to create a phpMyAdmin interface for the database, but I don't have experience with this.
I need the solution to be free, please.
Thanks in advance.
phpMyAdmin is free. You just have to download and install it on the machine with MySql. You will also need a WAMP stack (PHP web server hosting, such as the free WampServer package) to execute the phpMyAdmin website, and open the ports in your router to allow viewing the webpage remotely. Also there might be configuration settings in phpMyAdmin to allow remote access, but all these things have been done many times before and you should be able to find lots of help by googling.
I have seen this question asked previously but can not find a clear explanation of what is/isn't possible and what workarounds migth be available.
I have an existing C# application that uses SQL CE to store local information. This database is only accessed by a single application and is stored in the user's appdata folder.
Some environments have the appdata folder redirected to a network share which causes SQL CE to throw an exception: "Internal error: Cannot open the shared memory region."
I have read that SQL CE 3.5 SP2 is supposed to allow connections to network shares again, and that SP1 does not, however I have not been able to get it to work. Has anybody had any success getting any version of SQL CE to work over a network share? And if so, what version/code did you use to get it to work?
I have tried using mode=Exclusive in the connection string with no luck.
Or alternatively, has anybody found a different workaround? The data needs to be stored in the user's profile as it is specific per user and should not be accessible by any other user on the system.
I updated the application to use SQL Express with local user instances which worked, but it created too many deployment issues for our customers. I ended up having to write a layer to use Access MDBs while we look at different database options.
My suggestion for writing desktop applications is DO NOT use SQL express or SQL CE for local storage.
I've used SQL CE 3.5 successfully on a networked drive with instances of an application running simultaneously on two networked computers. I was able to update records in the database from both locations.
I'm not sure what would happen if two users accessed the same record at the same time, however this is unlikely in my situation. Just include the database location in the connection string.
Store the data in a folder that is not redirected.
SQL Compact is a single-user, in-process database engine.
Have you tried to put sqlce DB on a shared folder and set its datasource where it is located?
Something like:
"Data Source=\\MySharedfolder\\DB.sdf;Persist Security Info=False;"