从Web配置连接字符串中通过Web配置创建app.config [英] to create app.config from web config from the web config connection string

查看:63
本文介绍了从Web配置连接字符串中通过Web配置创建app.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

这是我在mvc项目中的web.config。我必须使用相同的连接在C#中编写一个小程序。如何在app.config中重写以下连接

< add name =" Conn1"的connectionString = QUOT;元数据= RES://*/DB.ShiftAppModel.csdl | RES://*/DB.ShiftAppModel.ssdl | RES://*/DB.ShiftAppModel.msl;提供商= System.Data.SqlClient的; provider connection string =& quot; Data Source = mySql\SQLEXPRESS; Initial Catalog = Mydatabase; Persist Security Info = True; User ID = myuser1; Password = mypwd1; integrated security = True; MultipleActiveResultSets = True; App = EntityFramework& quot ;"的providerName = QUOT; System.Data.EntityClient" />
< add name =" Conn2"的connectionString = QUOT;元数据= RES://*/DB.Employee.csdl | RES://*/DB.Employee.ssdl | RES://*/DB.Employee.msl;提供商= System.Data.SqlClient的; provider connection string =& quot; data source = EmpLive; initial catalog = Employee; persist security info = True; user id = myuser2; password = mypwd2; MultipleActiveResultSets = True; App = EntityFramework& quot;"的providerName = QUOT; System.Data.EntityClient" />








< add的ConnectionString = QUOT;元数据= RES://*/DB.ShiftAppModel.csdl | RES://*/DB.ShiftAppModel.ssdl | RES://*/DB.ShiftAppModel.msl;提供商= System.Data.SqlClient的; provider connection string =" Data Source = SRV-VM-GENIE \ SQLEXPRESS; Initial Catalog = ShiftApp; Persist
Security Info = True; User ID = pailypol; Password = bt746gf $; integrated security = True; MultipleActiveResultSets =真;应用=&的EntityFramework QUOT;"名称= QUOT; ShiftAppEntities" providername =" System.Data.EntityClient">< add connectionstring =" metadata = res://*/DB.Employee.csdl | res://*/DB.Employee.ssdl | res:// * /DB.Employee.msl;provider=System.Data.SqlClient;provider
connection string =" data source = srv-vm-qbptms; initial catalog = tmsv6live; persist security info = True; user id = shift;密码= india123; MultipleActiveResultSets = TRUE;应用=&的EntityFramework QUOT;"名称= QUOT; dev_shiftappEmployeeEntities"的providerName = QUOT; System.Data.EntityClient">< /添加>< /添加>



polachan

解决方案

重写成app.config是什么意思?可以假设一个人只会创建一个app.config文件,这是VS中的一个选项,即"添加新项目"的Windows模板,只需将连接字符串复制/粘贴到app.config即可。

This is my web.config in an mvc project. I have to write a small program in C# using the same connection . How can I rewrite into app.config the following connection

<add name="Conn1" connectionString="metadata=res://*/DB.ShiftAppModel.csdl|res://*/DB.ShiftAppModel.ssdl|res://*/DB.ShiftAppModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=mySql\SQLEXPRESS;Initial Catalog=Mydatabase;Persist Security Info=True;User ID=myuser1;Password=mypwd1;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> <add name="Conn2" connectionString="metadata=res://*/DB.Employee.csdl|res://*/DB.Employee.ssdl|res://*/DB.Employee.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=EmpLive;initial catalog=Employee;persist security info=True;user id=myuser2;password=mypwd2;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />


<add connectionstring="metadata=res://*/DB.ShiftAppModel.csdl|res://*/DB.ShiftAppModel.ssdl|res://*/DB.ShiftAppModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=SRV-VM-GENIE\SQLEXPRESS;Initial Catalog=ShiftApp;Persist Security Info=True;User ID=pailypol;Password=bt746gf$;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" name="ShiftAppEntities" providername="System.Data.EntityClient"><add connectionstring="metadata=res://*/DB.Employee.csdl|res://*/DB.Employee.ssdl|res://*/DB.Employee.msl;provider=System.Data.SqlClient;provider connection string="data source=srv-vm-qbptms;initial catalog=tmsv6live;persist security info=True;user id=shift;password=india123;MultipleActiveResultSets=True;App=EntityFramework"" name="dev_shiftappEmployeeEntities" providername="System.Data.EntityClient"></add></add>


polachan

解决方案

What do you mean by rewrite into an app.config? One would assume that one would just make an app.config file, which is an option in VS off of  'Add New Items' the Windows templets and just copy/paste the connectionstring to the app.config. 


这篇关于从Web配置连接字符串中通过Web配置创建app.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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