Click here to Skip to main content
15,885,665 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi. i have made a simple application in vb.net w/ a database(mdf)file. ived already made it an installer. i installed it on my pc and the program works successfully, i can add, save, delete.etc as it featured in my application. but the problem is when i installed it to other pc the application cant access to the database. does it also required to installed sql server to that pc(w/o sql server installed).Please help. im a newbie.
Posted

1 solution

If you have used SQL server in your application, then your "other pc" will need access to an instance of SQL server in order to work - and you will probably need to locate it and specify the connection string as part of your installer. You cannot use SqlConnection, SqlCommand and such like objects in your code without an installation of SQL server being accessible to each and every PC that is expected to run the application.1

There are ways round this: If you are using the database as a standalone data store (which will not be accessed by more than one application or user at a time) then you can change your code to use Access/Jet, or SQLCE, or SQLite - none of which require more than the appropriate Assemblies to be installed. Generally, it's not a major job to change your code to use them, it is mostly just changing SqlCommand to SqlCeCommand or SQLiteCommand objects and so forth. (There are exceptions to this, depending on what SQL server facilities you have used, but the basics normally go straight over)

[EDIT]
1 - This doesn't mean that you need to install SQL server with each application on each PC - in fact you definitely shouldn't!
[/EDIT]
 
Share this answer
 
v2
Comments
akosisugar 9-Jun-13 4:02am    
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True"

is this the way on how i set the connection string to my apps?
OriginalGriff 9-Jun-13 4:15am    
No. That would require an SQL installation on each PC that is to run your application. That is a very, very poor idea:
0) You can only distribute SQL Server Express for copyright reasons - not SQL Server full version.
1) They may already have SQL Server installed on the network. If so, then they will presumably want to use that version.
2) If they do have SQL server installed and you start proliferating SQL server Express instances, you are going to annoy the heck out of the database administrator...
3) A single site installation of SQl Server is a lot more likely to be backed up than a number of scattered version under user control.
4) Sql server is quite complex for a "normal" user to install and administer - it is not a good idea!
5) It will destroy the primary advantage of using Sql Server over SqlCE or SQLite - multiuser access. If everyone installs their own copy of SQL server, then you will have multiple copies of your database, each used by a single person. This will cause some confusion, and (depending on how you wrote the original database) may take some considerable effort to combine into a single instance when the problem is realized.
akosisugar 9-Jun-13 4:36am    
thank you sir! I totally understand now. this was a problem for me for many days and now i totally found a solution. this was a big help for me..thank you sir Griff! Accept Solution!
OriginalGriff 9-Jun-13 4:43am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900