我有一个Web应用程序,包括以下内容:
当我构建和部署时,Bin目录中没有设置文件或app.config,数据访问.dll,但更改web.config文件中的连接字符串不会相应地更改数据库 - 因此连接字符串必须被编译成数据访问dll.
我需要的是我的整个部署的一个配置文件 - 网站,数据访问dll,一切 - 有一个连接字符串被使用.目前,似乎有多个连接字符串在整个地方被使用或硬编码.
我如何才能最好地解决这个烂摊子?
谢谢你的帮助.
我想知道从asp.net中的web.config文件获取连接字符串的方法.
我只知道以下方式.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
namespace Sherserve.DataAccessLayer
{
public class DBGateway
{
public static string conString;
public DBGateway()
{
conString = ConfigurationManager.ConnectionStrings["test"].ToString();
}
}
}
Run Code Online (Sandbox Code Playgroud) 对于属性:
Persist Security Info=true
Run Code Online (Sandbox Code Playgroud)
和
Persist Security Info=false
Run Code Online (Sandbox Code Playgroud)
你能告诉我他们之间的区别是什么,如果我不把它放在我的连接中会发生什么?
connect.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=C:/Users/Nourah/Downloads
/Phase3/Salary.accdb;
Persist Security Info=False;";
Run Code Online (Sandbox Code Playgroud) 我使用.NET Framework 4.6在Visual Studio 2015中创建了一个新的Azure WebJob项目.
在app.config中,我设置了三个连接字符串:
AzureWebJobsDashboard和AzureWebJobsStorage连接字符串是相同的,它们都指向我的存储帐户.我包含了一个连接字符串 - 因为它们都是相同的,除了"名称".
<add name="AzureWebJobsDashboard" connectionString="DefaultEndpointsProtocol=https;AccountName=mystorageaccountname;AccountKey=thisIsTheLongPrimaryKeyICopiedFromAzurePortalForMyStorageAccount" />
Run Code Online (Sandbox Code Playgroud)
一切看起来都对我,但我收到以下错误:
未正确设置Microsoft Azure WebJobs仪表板的配置.在Microsoft Azure网站配置中,必须使用以下格式设置名为AzureWebJobsDashboard的连接字符串:DefaultEndpointsProtocol = https; AccountName = NAME; AccountKey = KEY指向存储Microsoft Azure WebJobs运行时日志的Microsoft Azure存储帐户.
顺便说一下,我知道web作业正在读取app.config,因为我的代码能够连接到我的数据库并更新一些记录.
知道我做错了什么吗?
将网站部署到运行IIS7的Windows 2008 r2服务器时遇到问题.我之前已将另一个站点部署到此服务器.Web部署正在连接并将我的文件复制到服务器,但我看到以下错误.
1 The 'Connection String' argument cannot be null or empty
2 Web deployment task failed.((20/07/2012 14:19:16) An error occurred when the request was processed on the remote computer.)
(20/07/2012 14:19:16) An error occurred when the request was processed on the remote computer. Could not find a part of the path 'C:\Users\Me\Documents\Visual Studio 2010\Projects\MySite\MySiteClient\obj\Release\AutoScripts\EFDbContext-Deployment_SchemaOnly.sql'. 0 0 MySiteClient
Run Code Online (Sandbox Code Playgroud)
我已验证该路径存在于我的本地计算机上.
我尝试使用web.config转换发布,并使用xdt:transform函数设置远程服务器字符串.
我还在Package/Publish SQL选项卡中显式设置了目标和源数据库的连接字符串,但是我不知道问题是什么.
有任何想法吗?
iis-7 connection-string visual-studio-2010 visual-studio webdeploy
在Windows Azure(预览)管理门户中,您可以更改网站的配置选项(请参阅http://www.windowsazure.com/en-us/manage/services/web-sites/how-to-configure-websites/ #howtochangeconfig).
我目前通过Web.Release.Config为我的ADO.NET实体框架连接设置连接字符串,但我想通过管理门户设置它,但无论我使用什么,我总是最终得到以下错误:
指定的命名连接在配置中找不到,不打算与EntityClient提供程序一起使用,或者无效.
它适用于常规连接字符串,即没有定义元数据和映射信息的元数据键(csdl,ssdl,msl).
这是我做的:
在"连接字符串"下,我有一个名为"ApplicationServices"的键,如下所示:
Server = tcp:xxxxx.database.windows.net,1433; Database = xxxxx; User ID = xxxxx @ xxxxx; Password = xxxxx; Trusted_Connection = False; Encrypt = True; Connection Timeout = 30;
这个工作.
我有另一个用于Entity Framework连接的密钥.我们称之为一个FooBarContext.它看起来像这样:
metadata = res:// /Models.FooBarContext.csdl|res:// /Models.FooBarContext.ssdl|res://*/Models.FooBarContext.msl;provider=System.Data.SqlClient;provider connection string ="Server = tcp:fooserver.database.windows.net,1433; Database = foobar; User ID = myname @ fooserver; Password = xxxxxxxxxx; Trusted_Connection = False; Encrypt = True; Connection Timeout = 30;"
这个导致上述错误.它是从Web.Release.Config中的工作值复制的,带有" 取而代之的是".
我尝试了其他变体:" 未触及,最后添加了元数据,但无济于事.我已经通过第二个网站重现了这个问题.
deployment entity-framework connection-string azure azure-web-sites
我有2个连接字符串 - 1个本地,1个用于我的主要生产服务器.当我安装它时,实体框架将App = EntityFramework添加到我的本地字符串(4.1) - 我现在在4.3上.这是做什么的 - 我找不到任何参考?
这是我的本地连接字符串:
<add name="LocalConnection"
providerName="System.Data.EntityClient"
connectionString="metadata=
res://*/;
provider=System.Data.SqlClient;
provider connection string='
Data Source=.\SQLEXPRESS;
AttachDBFilename=C:\mypath\MyDb.mdf;
Integrated Security=True;
User Instance=True;
MultipleActiveResultSets=True;
App=EntityFramework'" />
Run Code Online (Sandbox Code Playgroud)
只是好奇!
在调试中使用我的项目我没有问题.但是在IIS中运行它我收到此错误:
System.Data.SqlClient.SqlException:用户'domain \name-PC $'登录失败.
堆栈跟踪
[SqlException (0x80131904): Login failed for user 'CAPLUGSLLC\OETINGER-PC$'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +6749670
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +815
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4515
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +84
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +53
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +368
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) …Run Code Online (Sandbox Code Playgroud) 在一个公共代码库上工作,一个开发人员运行SQL Server Express 2005,另外两个运行SQL Server 2005.一切正常,但连接字符串不同.为了维护常见配置和构建脚本,我们希望将"localhost\sqlexpress"屏蔽为"localhost",就像其他2个开发人员一样.
可以这样做吗?或者,也许有一个更好的方法让所有3个在同一个连接字符串上运行...所寻求的解决方案是所有3个能够在代码存储库中的相同文件版本上运行.
我可能不是100%清楚:基本上我想要这个:
Data Source=localhost;Initial Catalog=Sample;Integrated Security=True
Run Code Online (Sandbox Code Playgroud)
连接完全相同:
Data Source=localhost\sqlexpress;Initial Catalog=Sample;Integrated Security=True
Run Code Online (Sandbox Code Playgroud)
如果可能的话.
我一直在尝试编辑我的连接字符串,以便将我的网站上传到服务器.
我对此并不十分熟悉.我遇到了这个例外:不支持关键字:'server'.
这是我的连接字符串:
<add name="AlBayanEntities" connectionString="Server=xx.xx.xxx.xxx,xxxx;Database=AlBayan;Uid=bayan;Password=xxxxx;" providerName="System.Data.EntityClient" />
Run Code Online (Sandbox Code Playgroud)
我已经尝试将此字符串嵌入到我的旧连接字符串中,该字符串在本地工作得非常好,但它不适合:S
asp.net ado.net entity-framework connection-string sql-server-2008