如何在Asp.Net中创建一个Sql Db? [英] How Can I Creat A Sql Db In Asp.Net?

查看:53
本文介绍了如何在Asp.Net中创建一个Sql Db?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我创建了一个db收到此错误:

连接到SQL Server数据库文件(.mdf)需要SQL Server 2005

express或2008安装并运行在本地计算机上。





我的Visual Studio是2010

Sql Server是2012

While i creat a db received this error:
connection to SQL Server database files(.mdf) require SQL Server 2005
express or 2008 to be installed and running on the local computer.


My visual Studio is 2010
Sql Server is 2012

推荐答案

您不应该在Web应用程序中创建数据库文件(并且您的问题是基于Web的ASP.NET):请记住,这些本质上是多用户的,并且创建是本质上是对任何现有版本的破坏性过程。

您要做的是预先创建数据库,并将其作为初始发布过程的一部分添加到现有的SQL Server实例中。



如果您的网络托管服务上没有安装SQL服务器,那么您需要添加它,或更改托管公司!



如果您仍处于开发阶段,并且您没有在本地安装SQL服务器,则ou应该:检查生产中可用的版本,并从MS下载它的Express版本:http://www.microsoft.com/en-us/sqlserver/get-sql-server/try-it.aspx [ ^ ] - 它将包含用于创建您本地PC上的数据库,因此您将在发布时获得用于生产服务器的示例。
You shouldn't be creating database files in web applications (and your question is ASP.NET, which is web based): remember that these are inherently multi user, and creation is inherently a destructive process to any existing versions.
What you want to do is pre-create the database, and add it to an existing instance of SQL Server as part of your initial publication process.

If you don't have SQL server installed on your web hosting service, then you need to get it added, or change hosting companies!

If you are still at development stage, and you don't have SQL server installed locally, you should: Check what version will be available to you in production, and download the Express version of that from MS: http://www.microsoft.com/en-us/sqlserver/get-sql-server/try-it.aspx[^] - it will include the tools to create the databases on you local PC, so you will have a sample to use for your production server when you get to publication.


这篇关于如何在Asp.Net中创建一个Sql Db?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆