Installing SQL server 2005 and creating database during setup wizard in c# - c#

I have a c# application that which contains a database in SQL server 2005.
I wish to first install sql server 2005, create the database, tables in that database during run time i.e. during installation of my c# application. The setup wizard should install all this and then install my c# application.
I went through msdn walkthroughs but the solution is in visual basic.
Please help.

After installation of your application, first check your DB on Login form / Start up form. If your DB not exists in DBMS, restore the back of your DB at run time.

Related

trouble with initial setup and connection to microsoft sql server from Visual Studio

I am on a Windows 10 machine, which has Visual Studio 2015. I am now trying to do projects with a database on the same machine. I seem to have SQL server ( I am really new to Databases ) Here is why I think I have a Database, which I can use:
C:\Users\zohal>wmic product get name,version | findstr "SQL"
Microsoft SQL Server Compact 4.0 SP1 x64 ENU 4.0.8876.1
When I try to connect to a database from Visual Studio I do the following:
click on Project > Add New Data Source new Window Comes up
select Database new Window Comes up
select Dataset the only option available, new Window Comes up
select NewConnection new Window Comes up There are six options
select Micorsoft SQL Server new Window Comes up but the pulldown is blank. I looked in the services section of Computer Management application, and do not see a SQL service running. I want to know how do I connect to this SQL server and does it work for what I want to do, which is to run .Net C# code with SQL statements?
Update...........
Guys, thank you for the content and advice. I have tried both SQL compact and SQL Express, and ran into the following problems. I wonder if you can help, or perhaps I'll create a new post. I have tried everything I could think of. 1) I tried to use the SQL compact. Got as far as "Creating a SQL server Compact Database". When I right click on the "App_Data", I just don't see an option of "SQL Server Compact 4.0 Local Database" as it stated in the procedures. Here is an of what I see. I did a search online for this type of issue, and the solution was to install a tools package. I did that. In fact I ran the Visual Studio install file, and chose the modify option and added all the tools, and support packages I could think of. I rebooted the machine also; no change.
I also ended up installing SQLExpress, and followed this link to set it up, but when I click on a new connection option I do not see the SQL Express option in the server name pull down as it states in the procedure. I basically get as far as creating the project and three steps into the procedure. I can put the projects on Git if that helps. My immediate goal is to create a table and query it. Here the code in my project:
var query = from c in db.Customers
where c.City == "Nantes"
select new { c.City, c.CompanyName };
Right now, I get an error under "c" and "db" as I have not created a connection. While I don't know how to do that yet, I do know that is not a huge task. But if I can not connect to a Database, this does not help me much. I did find the right assemblies and added them to the beginning of my project. I am talking about
using System.Linq.Expressions;
using System.Data.SqlServerCe;
Just tell me what to do. Should post again or can help me?
Update: Thank you. The MVC .Net Core MVC procedures worked. Thank you so much.
SQL Server Compact is not a full fledged database service. It is a way to store data in a file and run sql like queries against it.
Here is a short walk through of how to connect to a sql compact database: https://msdn.microsoft.com/en-us/library/gg606540(v=vs.100).aspx
If you want to use an actual sql server you can download and install SQL Server Express for free. Here is a walk through for that: https://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application
Both of the linked examples use Entity Framework to connect which is an ORM. There are many ways to connect to a database in C#. But since you mentioned running sql statements directly you may want to look into Dapper.Net which is a mirco ORM that let's you run SQL statements and map the results back to objects.
If you are not developing mobile (win mobile) apps, you need to download SQL server express edition which is suitable for any database application built for .NET and targeting the desktop/web apps.
To install the latest SQL express 2016, please visit this link or do some search on the web:
https://www.microsoft.com/en-us/sql-server/sql-server-editions-express
I would first verify in "Control Panel > Programs > Programs and Features" to check whether SQL Server is installed on the machine. You should see program with name "Microsoft SQL Server 20xx Setup". If you don't see any such names, then I suggest you to download and install a fresh copy of SQL Server.
Microsoft® SQL Server® 2014 Express
If you do see it in control panel, then open RUN (Windows Key + R) and type SSMS and press enter. This should open SQL Server Management Studio. (Sometimes SQL Server might be installed but Management Studio might not be. You can download Management Studio as well from the link provided above)
After opening management studio, enter the server name and click on "Connect". If you don't know server name enter . (dot) and click "Connect". Now you should be connected to SQL Server.
You should be able to connect C# code with SQL Server using a connection string.
Different formats of connection strings
How to store connection strings in web.config or app.config
Execute a command in c# by connecting to SQL Server

Creating application without SQL Server Management Studio

I created a window application in which I used SQL Server as backend database. But I want to know that is there a way through which we do not need SQL Server Management Studio to be installed on system?
I used Entity Framework with a code-first approach which creates database automatically but needs connection string for that. I need a way through which I can provide connection string of SQL Server Express without installing Management Studio.
You only need to install SQL Server, Management Studio is just for an easier database and server management, but it's not required to make SQL Server services work.
Try using SQL Server Data Tools (SSDT). You can create, manage and deploy SQL Server code right from Visual Studio.
It's built into VS 2013 and up and can be downloaded as an addin all the way down to VS 2010.
https://msdn.microsoft.com/en-us/library/mt204009.aspx

Deploy An Application with database

I have Created an application in C# and used SQL server 2012 for database. I have made the setup file for the app as well. Now I want to Install the App on the target machine.How to go? Where will i have to place the database and how to pick database from my machine? Note:I don't want to create a new database on target machine.Please Help
To deploy a C# application, follow the instruction below
install .Net Framework
Install the Sql Server
Restore the Database , How to restore SQL Server database through C# code
Run the project

Want to debug SQL Server 2008 R2 stored procedure from VS2012 - Cannot see database in the SQL Server Object Explorer

For the first time I am trying to debug a SQL Server 2008 R2 stored procedure being called by ASP.NET web app in Visual Studio 2012; application targets .NET framework 4.0.
I brought up the SQL Server Object Explorer for the first time. I see the system database, but there isn't even a node for the user databases. What am I missing? Hopefully there is a simple answer to this.
Make sure you open the right database. By default, it shows SQL Express so if you use another database, you need to connect to it manually.

build setup file for Windows application by including DB?

I have created windows application using windows c#.net and ms sql server 2008. And i am going to build setup file including database. Is that possible to build a setup including DB with out installing MS SQL Server 2008 in my client system?. If possible, this helps no need to install SQL server in my client system or else give a possible feedback. Thanks in advance.
You won't be able to load and use the database without a server running somewhere. Now, you could install that database on a remote server that is provided during installation - but a server has to be running somewhere.
Even loading it via file requires SQL Express to be running.
You can convert database to file (by detaching database) and then add that file to your project.

Categories

Resources