Deploy WPF Application with SQLite - c#

How do I get a WPF application, with A SQLIte database, on another PC? When running the code on the machine on which the app has been developed, there is no problem. But I cannot get the program to run on another PC.
I have been searching the internet for days. All literature are either vague or does not show the process from A to Z. Following the dozens of instructions on the net gives me results that either 1) Does not include the Database when the application gets installed on another pc, or 2 crashes the program. And the Microsoft literature talks alot but explains nothing.
How does the app knows in which folder to find the Sqlite database?
How does the app knows it must interact with the database?
What should the code look like to work on the other pc? What should the XAML look like to work on the other PC? And, PLEASE, in which classes or windows should they be?
By now I now in detail how to do all of the above for my local PC. I cannot get the app to run on another PC

Yes,yes,yes!!!!
I found the solution! In the App.config page, the connectionstring must be as follows:
">"
">" "connectionString="metadata=res:///SalaryAndWageApp.csdl|res:///SalaryAndWag">"eApp.ssdl|res://*/SalaryAndWageApp.msl;provider=System.Data.SQLite.EF6;provid">"er connection string='data ">"source="|DataDirectory|\WageAndSalaryApp.db"'" ">"providerName="System.Data.EntityClient" />
With the "|DataDirectory|\WageAndSalaryApp." working the magic

Related

How to create a C# program setup wizard, containing a SQL Server connected database?

I am developing a C# Windows Forms project in Visual Studio which contains a SQL Server database.
Everything is working great I have connection string saved in Properties.Settings... but when I install program on a different computer, it doesn't have data from database.
Of course I know that I have to add database to the other computer too, but can I do it without installing complete SQL Server?
Here is a picture of my connection string in settings.
I know that there are a lot similar questions like this out there, but more than I am reading those answers more lost I am.
Thank you for every clean explanation and answer or just link on great tutorial!
Have a nice day!

C# application on a shared drive / site / what else?

Hello all,
I just created a C# application that connects to a server database, it can insert, update, search, delete the files from the database, more than this I can view all the files in a listview.
I have encountered the following problems:
1) I don't want the application to be instaled on every PC from work, I want it to be instaled on a shared drive and every PC can open the application from a folder inside that drive (I don't want them to connect remoutly to my PC). I heard that there would be an another solution, that I can put my app into a Site (I have no idea how.. never did that before);
2) I have no idea how many PC can use the application at the same time ( but somehow I don't think that should be a problem because I tried inserting into the database through SQL manager at the same time with a mate and there were no problems) but if I put the application to be shared from the same drive it could cause problems;
3 I would love some tips how to make my application work nicer ( it started getting laggy after a few show/hide text boxes and labels..
Well the most important for me would be point (1), I have no idea how can I do this, I am sure that it is possible somehow, I accepted doing this C# app without knowing like anything but now it makes me curious like hell!
Thank you in advance! (sorry for bad english)
Image:
my first C# applicatipon
You can use something like ClickOnce so the users can download and execute your app.
From the site:
You can publish a ClickOnce application in three different ways: from
a Web page, from a network file share, or from media such as a CD-ROM.
A ClickOnce application can be installed on an end user's computer and
run locally even when the computer is offline, or it can be run in an
online-only mode without permanently installing anything on the end
user's computer.
Either that or convert to windows forms application to a web based application using ASP.Net.

Redirect from a database on a server to a local for testing

So I am assigned a projet on a company where I am to fix up and add some features as a side-project for the company. I have a almost complete website (13 000 lines of code or so) in C# and JavaScript. I have a local copy of the website and the database and I want to just toy around with my local database so I can try things out and not ruin the entire website/database.
I am relatively new to JavaScript and I kind of understand C# by now. I think I have found where I am supposed to change the database connection but not sure how I am supposed to do it, or what to change it to. The local database is on my desktop, next to the local copy of the project if that helps. This is where I figured I should change:
<connectionStrings>
<!--add name="MySqlConnection" connectionString="DATA SOURCE=11.11.111.11;
DATABASE=websitename;USER ID=websitename;PASSWORD=xxxxxx;PORT=1234"/-->
<add name="MySqlConnection" connectionString="DATA SOURCE=localhost;
DATABASE=websitename;USER ID=username;PASSWORD=xxxxxxx;PORT=1234"/>
</connectionStrings>
Also: shouldn't I be able to test this locally when I have no internet connection? Because right now it seems that I can't. Any tips are good tips. The weird thing is that the code wasn't runnable because of 2 errors (2 functions took 37 and 38 arguments instead of 38 and 39) and after I fixed that I could run the program in Visual Studio through Google Chrome. This should imply that the local code is running - right?
Well...if I change some hard-coded text on the website or add something in the menu it doesn't change when I run the program - this would imply that it's the version on the server running when I do it. But then why would it not run with the errors (that somehow doesn't bother the website for some reason)
I am very confused right now...sorry for a long post. Any help would be great.
lots of vague questions. Strip it down to essentials.
When you build the project in visual studio you can choose where to deploy it. It sounds like in IIS the folder is set to something other than your build folder (which is fine) but that means you have to redeploy when you build to see the changes.
if local host is requiring an internet connection make sure your hosts file in windows is configured properly.
you found the right area (maybe) for hte connection string - depends on how its coded up in the app though. It doesn't look like you are using a sql server database though because you have no provider info in the string. So you need to break this into several questions because there could be a chunk of code for each part.
If your live and local database stored information is not parallel then For testing purpose generate a database script from live database with schema and data.Then deploy it to local IIS.There is no need for internet for localhost database.

DevFC.exe (Development Fabric) for Windows Azure Crashes

Whenever I debug my application (ASP.NET Web Application converted to Web Role), I am able to get to the login page. I go ahead and sign in, debug through that and it seems to work fine, but as soon as it takes me to the landing page after login, DevFC.exe stops working with the error:
An unhandled exception ('System.Net.Sockets.SocketException') occurred in DevFC.exe [8072].
Now, I've searched for the issue and have seen something about DevFC.exe crashing due to VMWare Workstation that listens on the same port (12000) and HTC Sync that also listens on that port. I have neither of those applications on my machine, so I am lost here. Using TCPView (from Sysinternals), I find no other application using that port.
The one thing I do notice is that [System Process] goes crazy creating connections to localhost:12000 once DevFC.exe gets started.
Anyone have some insight on this?
This might sound ridiculous but restarting your machine might solve the issue. If that doesn't work, try your project on a different machine. If the project works then there is an issue with your primary machine try uninstalling then reinstalling the Azure SDK. If the devFabric still crashes on the secondary machine then it's something related to your project.
You might want to take a look at the logs created in the DevFC folder here: %localappdata%\dftemp\DevFCLogs (C:\Users\[user]\AppData\Local\dftmp\DevFCLogs). This will hopefully shed light on the actual error (which in my case, was a conflict on port 12001. Ran netstat -ab afterwards and found it was vmware-hostd.exe. This is a service included with VMWare Workstation 8. I know you said you don't have that, but you may have some other conflicting software).
See this thread as well for more detail.
http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/7e205afd-4b9a-4387-8e10-99e4b8f27788

Develop a data centric, multi-user windows application using Visual Studio 2010

So, after tinkering with programming for about 3 months now, I find myself in a situation where I'd like to try to develop a database windows application that can be used by a few users on my office network.
What I'm trying to do is create a simple property database for my small company that can be accessed by the half of a dozen co-workers.
The issue I'm coming to head with, is that I'm not really sure if I'm creating my windows application the correct way in order to share a single database on a server on our network. I have created, what I believe to be, a single user application with an express 2008 DB. However, I am not sure if I can take this program and migrate it to a multi-user program.
I've been trying to search for a quick guide with maybe some hints and tips of how to initially setup the project to correctly deploy the project as a multi-user application. However, I've been unable to find anything of relevance.
I really have no problem re-creating the project from start to finish, as it's good practice and I'm sure I have inefficient code in many places. I just need somewhere to start.
All of our machines are using WinXP and I'm pretty sure we have SBS 08.
Noob appreciation would be granted to those who help and thanks for your time.
Edit: I'm using Linq-to-Entities, if that means anything.
most likely you will have a local DB with your application. To make it a multi-Client one, you need to host the DB at a central place. Now you need to supply all clients with the correct connection string to access your DB.
Check the syntax for the connection string here: http://www.connectionstrings.com/
If you did everything right, that should be it (well... Excluding blocking issues, concurrency, update methods and validation ect... Who will win if 2 guys work on the same record...)
But those questions would require a whole new chapter ;)
The way to do is keep your application the way it is and put the database in a central place.
Then set the connection string correctly to point the app to the central database.
Like this: Suppose you have installed sql server on a machine named mypc then the connection string will be like: "data source = mypc ; initial catalog = mydb ; integrated security = true"
what that means is,
The database named mydb resides on a server called mypc. So that your app can access it. You do not need to worry about anything else. SQL server will handle other things for you. Also you can use sql express for this too. Just modyfy the conn string to
"data source = mypc\sqlexpress ; initial catalog = mydb ; integrated security = true"
If your application Requirement is multi user and within a single office (Same place) with having LAN Connection then the you can go for the windows application and the same application deployee on the multiple system in the office and set the single database for the all application so that you can use the application on multiple machines with a single database.
In this way you dont need any changes in your application just you need to modify a single line of code in the app.config if u wish to change the application.

Categories