connection-string

Get connection string in class library project in a solution

淺唱寂寞╮ 提交于 2019-12-30 04:45:12
问题 In my .net 4 solution, i have two different projects- an web application project and a class library project. In web application project, database connection string is in web.config file. I would like to access that connection string from class library project. Is it possible? if yes, how? If there is any better approach to get connection string, please let me know. 回答1: To access it from your class library add a reference to System.Configuration then use System.Confinguration

What's the Option=N in the MySQL ODBC connection string?

家住魔仙堡 提交于 2019-12-30 04:01:08
问题 I have seen both Option=3 and Option=4 in connection string samples for MySQL ODBC but no explanation or documentation. What do those numbers mean? 回答1: The Option= value is the sum of the numeric values for various flags that specify how Connector/ODBC should work. Its default value is 0. From an older version of the Connector/ODBC documentation at web.archive.org: Option=3; corresponded to FLAG_FIELD_LENGTH (1) + FLAG_FOUND_ROWS (2) Option=4; was FLAG_DEBUG According to the current list of

Data source name not found and no default driver specified

做~自己de王妃 提交于 2019-12-29 09:28:06
问题 I am getting this error when I try to insert record in db. Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified my connection is : Application("Db_ConnectionString")= "DSN=dsnname;UID=xxx;PWD=xxx;" please help me asap. thanks in advance. 回答1: thanks for your answers. I myself fixed the error. Assigned wrong dsn name in my code. I changed it and now its working fine 回答2: I got this error on

asp.net mvc multiple connection strings

六月ゝ 毕业季﹏ 提交于 2019-12-29 08:24:10
问题 I am creating asp.net MVC Application using MVC 3.0. I have 2 users but the DataBase is the same. So, Is it possible to setup two connection strings or even more in web.config? when user login, I redirect it to his database, so then he can use his DataBase. So major issue here is to find out which user is logged in and use connection string for that user. I am using default mvc account controller and for example when i want to display welcome message for user in my view i type: if (@User

ASP.NET System.Data.EntityClient connection string help

99封情书 提交于 2019-12-28 23:49:29
问题 I'm running ASP.NET MVC on a shared server and I'm having problems connecting to SQL via System.Data.EntityClient. Below is the connection string that my hosing provider gave me to connect to SQL and the one that VS configured for my local machine during development, what should my connection string look like when I deploy to the server? From my hosting provider: <add name="WeddingsDBEntities" connectionString="data Source=<server name>; Initial Catalog=<db name>; User ID=<user ID>; Password=

Connection string using Windows Authentication

坚强是说给别人听的谎言 提交于 2019-12-28 02:28:07
问题 I am creating a website, but in the database I use windows authentication. I know that you use this for SQL authentication <connectionStrings> <add name="NorthwindContex" connectionString="data source=localhost; initial catalog=northwind;persist security info=True; user id=sa;password=P@ssw0rd" providerName="System.Data.SqlClient" /> </connectionStrings> How do I modify this to work with windows authentication? 回答1: Replace the username and password with Integrated Security=SSPI; So the

Keyword not supported: “data source” initializing Entity Framework Context

独自空忆成欢 提交于 2019-12-28 02:28:05
问题 I'm initializing Entity Framework Object context, and this gives me the keyword not supported error: metadata=res://*/MainDB.csdl|res://*/MainDB.ssdl|res://*/MainDB.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Workspace\vs\Leftouch\Leftouch.Web\Data\Leftouch.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;App=EntityFramework" I took the connection string directly from web.config which was working, and modified

A network-related or instance-specific error occurred while establishing a connection to SQL Server [closed]

青春壹個敷衍的年華 提交于 2019-12-27 17:39:09
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I deployed my asp.net web application on somee.com, whenever I login into this site (ipc.somee.com) it gives me a network related error like: A network-related or instance-specific error occurred while

SQL Express connection string: mdf file location relative to application location

痞子三分冷 提交于 2019-12-27 10:26:11
问题 I am using SQL Express databases as part of a unit test project in c#. My databases is located here: ./Databases/MyUnitTestDB.mdf I would like to use a relative path or variable in the app.config rather than having my connection string defined as: AttachDbFilename=C:\blah\blah\blah\yea\yea\yea\MyApplication\Databases\MyUnitTestDB.mdf I have seen the use of |DataDirectory| but am I correct in thinking this is only applicable to web applications? I want to control this in the application

Connection String Is not Working Object instance reference is null

痞子三分冷 提交于 2019-12-26 12:39:26
问题 //'Object reference not set to an instance of an object.' Please Do not mark it as redundant question . I have tried almost all the methods to make a connection string first one is by : string connectionString = ConfigurationManager.ConnectionStrings["ClinicalConnectionString"].ConnectionString; the second one : string connectionstringgg = Properties.Settings.Default.ClinicalConnectionString; third method is by : ConnectionStringSettings connectionSetting = ConfigurationManager