I try to write a Windows Forms Application, which should have a Data Source connection. I tried it for at least two hours now, but I don't get it. I tried to use a DataSet or a Service-based Database, but I don't know how to get access to the data.
I know how to set up my tables, that is not the problem.
I want to read/update/insert to my tables through the C# code without using SQL Commands. Is there an example code or tutorial anywhere?
I'm using SQL Server Express 2014 and Visual Studio Community 2015.
Thanks in advance
Related
Okay, so this is going to sound stupid or trivial, but please, humor me. I am writing a personal project in C# using Visual Studio 2013 Express and some of the code is going to hit a SQL database. Before I hit other databases, I want to test it locally and make sure that it performs as expected. However, I can't seem to find any tutorial that either is complete or works in order to get a SQL database up from nothing.
First, I tried installing SqlLocalDb 2014. Even after the tools I can't figure out where there is a UI that I can type in scripts to create a database.
I tried the directions here: http://www.wikihow.com/Create-a-SQL-Server-Database
But at step 3, the option to create a database is greyed out, and searching that issue got me nowhere.
I've tried adding a new SQL Server Database Project to my solution. This looked like it would work exactly, but when I designed the table I couldn't figure out how to actually deploy/publish it so I could connect to it. I get a SQL file, and I can't figure out what to do with it from there. I found instructions on how to publish it, but it seemed the only directions were to publish to a remote server (and I want to use a local one).
I tried the instructions here (yes, I know they're for 2012): http://msdn.microsoft.com/library/ms233763(VS.110).aspx but I can't find the Server Explorer / Database Explorer. I found the Server Explorer (where my table doesn't appear) and the SQl Server Object Explorer, where my table does appear but I can't figure out how to populate it with dummy data or how to connect to it.
This should not be this hard and I feel like I'm missing something obvious. Thank you in advance for any help.
Hitting F5 deploys your SQL Server Database to a localdb instance that you can connect your application to. You can see the connection string for this database by right-clicking on the project -> Properties -> Debug -> Target Connection String.
You can use this connection string in your application code to connect to the local database and test it - place it in a configuration file that can be replaced with the real database connection string in your production code. Alternatively use a database first Entity Framework Model to connect your application to your database, and you can just change the App.Config file to specify whether to target your test or production database. That's a really nice way to handle this since it will produce all the code you need to work with the database.
You could use xampp. From there you can create local databases and then you could talk to the created database using "localhost" instead of the productive server.
For the record there is some information on Accessing Data in Visual Studio at:
https://msdn.microsoft.com/en-us/library/wzabh8c4.aspx
And specifically to answer your question there is a "Walkthrough: Creating a Local Database File in Visual Studio" at:
https://msdn.microsoft.com/en-us/library/ms233763.aspx
I need in education to do win-forms app, recently I done project on asp.net, there I created without any problem new SQL Server database and send it to SQL Server, and added it to project.
But how can I do this using simple windows forms? Are there any good tutorials? (also I need something like db designer).
On asp.net mvc I use linq... But couldn't find good tutorial for create, send and attach SQL Server database on winforms.
I do this with .net 4.0 and SQL Server 2008 and Microsoft Visual Studio 2010
You can use Entity Framework Code First to design your db and then call Database.SetInitializer to create the database. Take a look at this article Understanding Database Initializers in Entity Framework Code First
I am making a small Windows application using Visual Studio 2010 and SQL server compact edition 3.5. I want to access Northwind.sdf database in my application but I am unable to make the connection string.
I have copied the database in my application as well as in the debug folder as I am trying to run application in debug mode.
Well you have got to give us a bit more than that. First of all are you trying to connect to the database using SqlConnetion or SqlCeConnection? Secondly, are you sure that path or you database is correct? You may also referre to the links below for more info.
Sql Compact 2008 Connection string Problem
Sql Compact Connection String
If you want any further help try to post the code you have done so far.
I have a problem with access database. I am developing a web application in visual studio 2010 using C#. I was using sql server 2005 as my database. Recently it is changed into Access. When I am trying to save some data to the Access database from my application it won't work. But when I am trying to do the same from Access itself it works correctly. What is the problem and what will I do for rectifying this problem.
There is some difference with query in ms-access.Like if you have to query with date column then you have to use #+date+# instead of '+date+'
How to create a simple Local SQL database & insert values into it using C#? can any one provide me a sample code or project link.. i googled a bit, i am not getting how to do..
if you can advice it would be great
If you are creating a Desktop application, you can create a local Sql server Ce (Compact edition) database.
When you install Visual C# 2008 Express, It will automatically install SQL Compact 3.5 on your box.
Here is an excellent Getting started tutorial on the topic:
http://dotnetperls.com/sqlce
I would use SQLite. It's simple and it doesn't need any kind of installation, the full database it's only a file.
Sql Server Compact is a great embedded database. It is also fully documented on MSDN, see System.Data.SqlServerCe Namespace.
You can easily create and modify databases programatically, see SqlCeEngine.CreateDatabase Method.
You can download it on the SQL Server Compact Download Page.