Adding SQL Server database to Visual Studio 2013 ASP.Net webpage - c#

I am trying to add a SQL Server database item into my ASP.Net website.
I have SQL Server 2012 installed but when I press add in Visual Studio I get the following error
Connection to SQL server database files (.mdf) require SQL Server 2005 Express or SQL Server 2008 Express to be installed and running on the local computer. The current version of SQL Server Express can be downloaded and at the following at the following URL: "
I am wondering if I can get it to work with 2012 in the way it would with 2005/2008 or will I need to download 2005/2008 to get this feature?
I only ask because it seems a little strange that VS2013 is not not compatible with SQL Server 2012...
PS: I am trying to follow the following tutorial and that is why I am hoping to get this to work so I can follow the tutorial as intended. "http://www.youtube.com/watch?v=Tyr1YXpNOrk"

by SQL Server Management Studio create your database, then in vs 2013 asp.net project use this database into web.config file
in vs 2013 and Server Explorer tab and Data Connections with Add Connection or Create new sql server database use from your db or create new sql 2012 db

I am wondering if i can get it to work with 2012 in the way it would with 2005/2008
What for? To my knowledge that was retired for the bad issues it created.
Visual Studio 2013 comes with an ad job user version of MSSQL (localdb) that is non-install-required and used in case.
Otherwise install the normal sql server and reate the db - do not rely on this functionality (like most non-trivial shops anyway) and no problem arises to start.

Yes It can be done through Visual studio and here is the link to guide A-Z
It will IIS to deploy ASP site.
http://www.asp.net/mvc/tutorials/older-versions/models-(data)/creating-model-classes-with-linq-to-sql-cs
Hope this will work as it worked for me

Related

Can not figure out, how local SQL Servers are installed and get connection string to them

I am trying to connect to a local SQL Server database (currently installed Microsoft SQL Server 2017 as shown in the screenshot) with C#. I've searched for about some SQL Server clients for C#, but in every tutorial or guide, there are always connection strings as a constant (can not figure out how to get it).
Some details:
Platform: Windows 10 - x64 bit
SQL Manager: Microsoft SQL Server Management Studio v18.2
IDE: Microsoft Visual Studio 2019
In addition: Can you guys tell me, how can I create new server? (I figured out that, creating new SQL Server on local machine is done by installing new SQL Server software or something?) I am so confused, because once, I had tried to uninstall some SQL Server softwares from the control panel, and suddenly server has disappeared. Any suggestions how can I install my own server for example? With name, that I want to call it.

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 application using installshield

I have developed an WPF application using .Net 4.0 framework. I have installed SQL 2012 Express edition on my machine .
My application performs basic CRUD operations on this database using appropriate connectionstring. I am very new to deployment. so my question is How can I deploy my mdf files at the client end ? I cannot install ~130MB of software at client end just for my 4MB of mdf files it doesn't make sense. Also while deploying project I saw this pre-requisites screen
My questions are:
(I think if i check SQL Server 2008 Express SP1 it will download it at client end) But I have SQL 2012 Express Edition Installed so how can I go with it ?.
Also is it possible If I give client seperate exe of my SQL 2012 Express edition ? (There is no need for management studio at clientside.so what should be given to client so it that installs only those software which are required to run .mdf file )
To answer your first question,
1. You will require a .prq file for SQL server 2012. Either you can create it or you can download it from web. You can add/edit '.prq' file from 'Redistributable' section.
For your second question,
2. You can pass the setup of aql 2012 express to your client with specific instructions to only install server and not the management studio.
You need SQL Server Compact most probably

Is it possible to run an application built on sql server 2008 to run with 2005

I have a .NET 4.0, SQL Server 2008 application built on VS 2010.
Since more than 10 months I have been working on a project and its completed now. I moved to the next task of creating an installation of the software. Its also done. But now I have a big issue.
My clients already run software running SQL Server 2005 and its installed on their system. However when I was packaging my VS2010 C# application, I deployed it with prerequisite of SQL Server 2008 but now the problem is, when I try to install my application, it asks to uninstall the 2005 and then to install 2008. But my clients are very rigid to allow my program to uninstall any application on their system. I am stuck here.
I also tried to remove it from my prerequisites and the application was successful to install itself but after when I tried to run my application, its unable to access the database.
How I can solve this issue? Is there any way to make application and database both work with SQL Server 2005 or 2008. Or maybe any other expert advice.
EDIT 1
I also have Datetime stuff which really annoyed with to accomplish, as my project is multilingual so I have separate functions to handle datetime to insert in SQL.
EDIT 2
Is it possible to upgrade SQL Server 2005 to 2008 using my own Visual Studio Deployment Project?
EDIT 3
This is the error I am getting
Prerequisite check for system component SQL Server 2008 Express failed with the following error message:
SQL Server 2008 Express Service Pack 1 (x64) cannot upgrade the existing instance of SQL Server 2005 Express (x64 WoW) named 'SQLEXPRESS'. Uninstall this instance of SQL Server 2005 Express and retry installing SQL Server 2008 Express Service Pack 1 (x64)."
See the setup log file located at 'C:\Users\BOOGI~1\AppData\Local\Temp\VSD41A1.tmp\install.log' for more information.
EDIT 4 (Main)
Is it possible to make a Microsoft SQL Server database file compatible to run with both SQL Server 2005 and SQL Server 2008?
It is usually not a problem to run an application against any version of SQL Server. Create the database using Management Studio and you're ready to go.
If you have a setup, you may need to change the prerequisites, so that it works with SQL Server 2005.
You may have to adjust the connection string. In the error message you're providing, it is obvious that the instance name of the SQL Server is "SQLEXPRESS", so you need to add this in your connection string.
Also, it is not a problem to run SQL 2005 Express and 2008 Express side by side.
One thing you can do is install SQL 2005 in your development machine or another machine then migrate your schema's and data from SQL Server 2008 to SQL Server 2005 and get your C# application working again. .NET 4.0 doesn't care which version of SQL server you are connecting to as long as you have the appropriate drivers installed for each appropriate database.
For your datetime create a function in SQL server so that it works in both version. Check out some examples in this link.
Thanks,
Kalagen

Can I create and connect to a SQL Server CE database if SQL Server 2005 isn't installed?

Is there any way to do this?
Update: Sorry, I should have included more information. I am trying to create and connect to a SQL CE database using System.Data.SqlServerCe in C# running on a PC (i.e. not running on a Windows Mobile device).
This code:
string connstr = "Data Source=\"" +
filename + "\";Persist Security Info=False;";
System.Data.SqlServerCe.SqlCeEngine engine = new SqlCeEngine(connstr);
engine.CreateDatabase();
... works fine on any PC that has SQL Server 2005 installed, but fails on any PC that doesn't have it installed. I'm trying to find out if there's any way to get this to work without installed SQL Server 2005 on the machine.
You can do it with Visual Studio - when you add a connection, change the data source from Microsoft SQL Server to Microsoft SQL Server Compact 3.5.
Also, if you mean the actual server - as opposed to the management tools - then SQL Server 2008 Management Studio [Express] can open SQL CE databases directly.
Edit: To create the database in Visual Studio, choose "Local Database" when you go to add a new item. That's a SQLCE database. And in SSMS[E], when you choose the SQL Server Compact option, you can choose "New Database" as an option in the Database File drop-down.
Edit2: In order to have code written against SQL CE run successfully on a vanilla target machine, you will need to install something on it, although not SQL Server 2005. SQL CE is a separate product (download page). It should also appear as a redistributable module in Visual Studio if/when you create an MSI installer for your product.
I assume that what you mean is can you create one with a tool, rather than with code. Studio can create them just by going to the Server Explorer and adding a new connection (you'll get the option to create one).
If you're looking for something a little nicer or something that doesn't require Studio, then Primeworks' Data Port Console is a really nice tool.
EDIT
If you need to create it through code then yes, you can still do this without Server installed. Make sure that you have the SQL CE Redistributable binaries (for the proper 32/64bit) deployed to the target and in a place the app can find them.
See locally at
C:\Program Files (x86)\Microsoft SQL
Server Compact Edition\v3.5
or online.
Just to add to what Aaronaught was saying, to connect to a SQL CE database programmaticaly, you don't either need SQL Server installed. CE runs in proc, and as long as the SqlCE dll's are installed (their part of the framework nowadays) then you should be able to connect to it without any issues.

Categories

Resources