How to connect sqllite to c# application - c#

Hello I am a new in C# and I have this problem. How can I connect my sqllite database in C#?
I created class named Connection.cs I know I have to get connectionString but I donĀ“t know how to set up it. In my project I have alredy database test.db in main project folder (I can see it in my project in VS)
Can you show me how to make this connection working (some example class or something)? My idea is that I am doing MVP design model so I have to use this connection in my models.
I would show you my code but there is not so much to show. I saw some videos how to connect this but thy always need nugget package to make connection working. Is this only way or is there other option to do it?

Refer to following article to get started with using SQLite in C# application.
https://www.codeproject.com/Articles/22165/Using-SQLite-in-your-C-Application
Recommended practice is to put your database file in App_Data folder of the application. Regarding database connectionstrings refer to following:
https://learn.microsoft.com/en-us/previous-versions/aspnet/jj653752(v=vs.110)
Following is a link to video series on YouTube that may be complete guide to what you are looking for.
https://www.youtube.com/watch?v=XHw4bBLM8Vk&list=PLT3ocvD4YC8iHBHQxFq13r-8rQyQxoJOx&index=1

Related

Pragmatically Open Database connection

I am working on a project and have scoured the internet for answers on this topic but could not find a single answer, not even an open source solution.
Maybe you guys could help me out.
In visual studio you can open the database connection window by browsing View -> server explorer -> add connection. that is all well and known but what if I wanted to open that same form from code or a certain API. I cant seem to figure it out but there must be some sort of way to access this form pragmatically since its native to Visual Studio.
For all who are unsure what form I'm talking about, here's a snippet:
So my question to you is, how can I , through code, open this window? If there is nothing built into Visual Studio and C#, do you know of any open source software that accomplishes this or will I have to recreate it with a windows form application?
I think you would need to build the form yourself if you need any custom logic etc in which case you could use the ConnectionStringBuilder classes and pass the validated fields from your custom form to the relevant builder class to generate the connection string. Visit here for more information.
Microsoft also has library on nuget that you could use, although it's deprecated so use with caution. The nuget file, which you can download manually, also contains the source code so perhaps you could use this to jump start your own UI component. https://www.nuget.org/packages/DataConnectionDialog

Enterprise custom field input by look up to external data MS Project Server

Hi i want to set a project custom field input like autocomplete look up from external data / external lists.
I am using MS Project Server 2013 system which in Sharepoint platform.
Actually, I have plan by modifying MS Project Server solution starter which made for custom field can look up from user group data. I have tried but it is difficult to change many things.
Is there any easiest way? Or maybe there is custom solution that has been made?
Please explain in simple way in c# programming or maybe javascript.
I'm not sure if there are any new features for that in 2013, but we synchronize external sources into Lookup tables assigned to Enterprise Custom Fields. We do that using PSI service MSDN Doc. And we do that using C# because only .NET supports DataSets which are the main data container to communicate with a Project Server through PSI

Setup up c# to save to local database when offline and update/send to mysql when online

I am making a application in c# for windows that is for field guys to mark what they did on a job. there is a proposal side to this that sales guys put in the proposal and it saves to a MySQL database. The proposal is all done online and is PHP. What my issue is the field guys will not always have internet available to them when they are filling out what they do so I need a way for them to be able to see what the proposal is for and then fill out what they did and save it locally. Then when internet is available for it to update the online MySQL with what they did. I am looking at exporting the proposal to XML and emailing it to the field person so my hope is they can import it into the c# and see what they are suppose to be doing. Then do the job filling out what they really did and send it back to the database once online.
While it would require the guys to have local MYSQL instances installed, another option would be to use microsoft synchronization services for .net from within the c# application.
Most examples you will find are for MS SQL, it works with anything that has an ado.net provider as illustrated here with Oracle.

What is the best way to develop a C# project with a MySQL backend?

So I'm using C# 2010 Express and wondering what the best toolset is for developing a C# project with a MySQL backend? I know what if you use SQL Server Compact edition from within C# it will let you access the DB directly from the IDE. Is there a similar way to integrate the development with a remote MySQL Database?
Also, is MySQL a versatile enough solution for writing a program with C#? I am looking to build a seperate PHP web site (a reporting portal) that will access the MySQL data. I'd love to go open source all the way, but it seems like C# is the best app to create the app I'm trying to create (touch screen interface for data entry).
Whenever I program a database related homepage I always use HeidiSql and mysql. Both of them are easy to figure out and fast to use.
From their site:
HeidiSQL is a lightweight, Windows
based interface for MySQL databases.
It enables you to browse and edit
data, create and edit tables, views,
procedures, triggers and scheduled
events. Also, you can export structure
and data either to SQL file, clipboard
or to other servers.
All you do is install Mysql, set up a pass and username. and it's up and running.
Then all that's left is to install Heidisql. Heidisql it is a free program. If you need more details on how to attach heidi to your database please do write again.
There is
http://www.devart.com/dbforge/mysql/fusion/
But it's not free and is a plugin which you can't use with Express. There is no way to do this with Express as you can't add onto the basic functionality.

build setup with database

I have written the code and finished the project. It is a window app in c#. I also have a database in sql server 2005 which I used it in the application. I need to create a setup for it so that any user can install it in his machine. build->publish and then following the wizard is the right way perhaps.. but what about the database?
The same database I made won't be in all computers, so I need that database also bind with my application.
Here is a link to some intro level tutorials, this should get you started. I would focus on creating some sample "Hello World" type applications before you dive into database programming. If you don't start small with this stuff, it can get frustrating.
http://msdn.microsoft.com/en-us/library/aa288436%28VS.71%29.aspx
it sounds like you are looking for basic information on setting up a project, to truly document this is going to take a lot more than a post.
The basic project setup, is done via Visual Studio and the "File" -> "New" -> "New Project" option. You can then select the type of project you need and that will then setup the project for you.
For the database conection, you will want to look into the items in the System.Data.SqlClient namespace.

Categories