在VS 2010 Ultimate Edition中将DB和编码部分保持在一起 [英] Keeping DB and coding part together in VS 2010 ultimate edition

查看:69
本文介绍了在VS 2010 Ultimate Edition中将DB和编码部分保持在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

  我正在做一个内部项目.最初是在VS 2005中使用MS SQL Server 2005开发的.

  现在我需要在VS 2010 Ultimate Edition中对该应用程序进行一些更改,

 主要变化是不是将数据库保留在单独的MS SQL SERVER中,我需要将数据库放入驻留在VS 2010本身中的SQL SERVER中(我指的是IDE本身的后端和前端).

我尝试了多种方法..我在APP_DATA文件夹中添加了新的SQL Server数据库(.mdf),并在示例表中添加了新架构..在web.config中添加了连接字符串属性,像这样,

< 添加 名称 = " = " " providerName " />

C#文件

SqlDataAdapter daSelect,daDisplay;   数据集 dsSelect,dsDisplay;

  受保护的 void Page_Load( 对象 发件人 EventArgs e) 如果 (!IsPostBack)

 

数据集 ();  

 

字符串 strcon = ConfigurationManager .ConnectionStrings [ "ConnectionString"" ].ToString();

 

  daDisplay =

SqlConnection
(strcon);

 

sqlcon.Open();

daDisplay.Fill(dsDisplay,

SqlDataAdapter
(

 

" Viewapp" );

GridView1.Visible =

 

sqlcon.Close();

}

 

 

{

 

{

dsDisplay =

 

sqlcon =

 

 

 

sqlcon;

  ....(即,当页面正在加载数据时,无法在网格视图中填充.......

我在运行时遇到的错误

尝试为文件D:\ vinoth \ PMO \ WebApplication2 \ App_Data \ pmo.mdf附加自动命名的数据库失败.存在相同名称的数据库,或者无法打开指定的文件,或者该文件位于UNC共享上.

请帮助解决此问题.

  我的目标是我希望保持我的数据库以及在IDE中一起编码..(我已经有.sql脚本文件,其中包含查询以创建我的proj表,如何添加,也让我知道)

 注意:尊敬的主持人,这不是我的家庭作业..我尝试了几次最终以多种方式来到这里.

 

 

span>

解决方案

你好,

       谢谢您的发帖!我建议您在( SQL Server > SQL Server论坛 > SQL Server集成服务)论坛位于此处: http://social.technet.microsoft.com/Forums/zh-CN/sqlintegrationservices/threads

       希望对您有帮助.
 
      祝你有美好的一天!


hi all,

    i am doing one internal proj.. initially it was developed in VS 2005 with MS SQL server 2005..

   now i need to do some changes in that application in VS 2010 ultimate edition,

  main change is instead of keeping DB in separate MS SQL SERVER i need to put my DB in SQL SERVER which reside in VS 2010 itself( i mean both back end and front end in IDE itself).

 i tried in multiple ways.. i have added new SQL server DB (.mdf) in APP_DATA folder and added new schema with sample table.. added connection string property in web.config like this,

<add name="ConnectionString"connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\pmo.mdf;User Instance=true"providerName="System.Data.SqlClient" />

in c# file

   

SqlConnection

 

 

 

 

SqlDataAdapter daSelect, daDisplay;  DataSet dsSelect, dsDisplay;

 protected void Page_Load(object sender, EventArgs e) if (!IsPostBack)

 

new DataSet();  

 

string strcon = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();

 

 daDisplay =

new SqlConnection(strcon);

 

sqlcon.Open();

daDisplay.Fill(dsDisplay,

new SqlDataAdapter("SELECT * from emp", sqlcon);

 

"Viewapp"); true;

 

 

GridView1.DataSource = dsDisplay;

GridView1.DataBind();

GridView1.Visible =

 

sqlcon.Close();

}

 

 

{

 

{

dsDisplay =

 

sqlcon =

 

 

 

sqlcon;

  .... (i.e) when page is loading data ill be filled in grid view.......

error i am getting in run time is,

An attempt to attach an auto-named database for file D:\vinoth\PMO\WebApplication2\App_Data\pmo.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

please help on this issue.

  my target is i want to keep MY DB as well as coding together in IDE.. ( i already have .sql script file which contains queries to create my proj tables how to add that let me know that too)

 Note : Dear moderator this is not my home work .. i tried it several times  in multiple ways and finally came here..

 

 

解决方案

Hello,

         Thank you for your post!  I would suggest posting your question in one of the ( SQL Server > SQL Server Forums > SQL Server Integration Services) forum located here: http://social.technet.microsoft.com/Forums/en/sqlintegrationservices/threads

         Hope this helps you.
 
        Have a great day!


这篇关于在VS 2010 Ultimate Edition中将DB和编码部分保持在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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