Good Practice - Connection String In Web.config?

Jun 30, 2010

Whats the difference, if in my web.config i use. both works with my code. what is right way of diong it? keeping connection string?

[code]...

View 4 Replies


Similar Messages:

Provider Connection String Of Entity Framework Be Substituted With A DB Connection String Already Defined In Web.config?

Feb 2, 2011

I have a db connection string 'ApplicationServices' defined in the connectionString section of web.config and 3 Entity Framework connection strings which have the provider connection string attribute with the same connection string as the one in 'ApplicationServices'. Is there a way to reference connectionString in 'ApplicationServices' for the provider connection string attribute of the EF connection string in the web.config, rather than providing the connection string all over again?

View 1 Replies

Web Forms :: How To Access Connection Connection String From Sub Folder Web.config File

Mar 15, 2011

just for my testing purpose i know i can define both the connection's outside in a single web config file by different name's and access them in my front end according to it but what if i want to have seprate for both connection's web.config situation is like this see image so i want to access my connections from second web config file how i can do that.

[Code]...

i tired this but its giving error

[Code]....

View 1 Replies

Making Ado.net Connection Class Or Connection String In Web.config?

Oct 18, 2010

I am preparing for an Access2007 db conversion at the beginning of the year and would like to know what the best process would be for connecting to the sqlserver2005 database. I have read about adding the connection string to the web.config file. I have also read about using ADO.NET and put the connection information into a class and not the web.config file.

I would like to hear from others as to what you have used, are using, or plan on using for a webapp (vs2010), and why so I can get an understanding.

View 3 Replies

Configuration :: Deploy Web.config And App.config Connection String?

May 3, 2010

I have deploy my web site, it contains a project!

in MyWeb there are all the aspx page and some entites datamodel, in MyApp there are the class with function like "getter data from DB" and there is a entity data model.

afeter the deploy, I have only the web.config and the connection string for the entity datamodel....itīs run ok, read/write the data on the DB.

The problem is with MyApp.....after the deploy it is a dll file and I donīt have the app.config and the entity inside it donīt run, not read/write nothing on the DB.

There arenīt error or messager but not read/write the data in the MyApp project.

all run on the iis 7

now...the question is:

I lose the connection string (in app.config) after the deploy?

Can I put a entity in the MyWeb and read it in another project (myApp)?

ps: for connect to DB I use not the c# code:

var db=from x in AccessDB.Example select x;

View 1 Replies

Good Practice When Retrieving SQL Data?

Jan 19, 2011

I'm currently using the fantastic DorkNozzle 'framework' for building a very basic blog in .NET.My first "self-taught" script is as follows, and is for solely retrieving SQL results.

PHP Code:

<%@ Page Language="C#" MasterPageFile="~/Dorknozzle.master" AutoEventWireup="true" Title="Blog" %>
<%@ Import Namespace = "System.Data.SqlClient" %>
<script runat="server">[code]....

I should change to perhaps improve my coding style, without going down the MVC line just yet?

View 17 Replies

Is This Modified C# Singleton Pattern A Good Practice

Feb 9, 2010

I'm developing a blog application shared by non-profit organizations. I want each organization to be able to change their own blog settings. I have taken a singleton pattern (from BlogEngine.net) and modified it. (I understand that it is no longer a singleton pattern.) I have tested this approach and it seems to work fine in a development environment. Is this pattern a good practice? Are there issues, which may arise when this is placed in a production environment?

public class UserBlogSettings
{
private UserBlogSettings()
{
Load();
}
public static UserBlogSettings Instance
{
get
{
string cacheKey = "UserBlogSettings-" + HttpContext.Current.Session["userOrgName"].ToString();
object cacheItem = HttpRuntime.Cache[cacheKey] as UserBlogSettings;
if (cacheItem == null)
{
cacheItem = new UserBlogSettings();
HttpRuntime.Cache.Insert(cacheKey, cacheItem, null, DateTime.Now.AddMinutes(1),
Cache.NoSlidingExpiration);
}
return (UserBlogSettings) cacheItem;
}
}
}

(Portions of code were omitted for brevity.)

View 3 Replies

Good Practice To Avoid Using Session State In MVC?

Mar 7, 2011

It's not explicitly written somewhere but I felt so after reading few blogs on ASP.NET MVC. Just got curious and thought of asking it here.

UPDATE: I'm not asking about memory/storage/RAM concerns on server. For them, there is a solution to store session out of process. I know that. I'm curious that, are there any scenarios where we had to use Session in WebForms but we can avoid it now in MVC taking benefit of the nice structured way offered by MVC?

View 6 Replies

C# - Is It A Good Practice To Implement Logic In Properties

May 27, 2010

we use ASP.NET with C# and based on open source projects/articles I passed through, I found many properties were including a logic but when I did so the team-leader told me it's not good at all to place logic inside properties but to call the logic through methods...

View 6 Replies

Getting Connection String Out Of App.config

Feb 1, 2011

I added a database to my project. When I did so an app.config file was added to my project. (Yes I know I have dangerous info in the connection string. I shall change that but for now I am messing around with test stuff.)

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="NyStories.Properties.Settings.storyConnectionString"
connectionString="Data Source=|DataDirectory|story.sdf;Password=driver;Persist Security Info=True"
providerName="Microsoft.SqlServerCe.Client.3.5" />
</connectionStrings>
</configuration>

I did a google search on how to get the connection string value and found. string sConn = ConfigurationSettings.AppSettings["ConnectionString"]; I am getting a warning that this is obsolete. It has been replaced by ConfigurationManager.AppSettings. Ok Fine. According to the docs, it is also in System.Confiuguration which I already have a using statement for above. But when I attempt to use it, it is not part of the assembly.

View 4 Replies

MVC :: More Than One Connection String In Web.config?

Feb 14, 2011

My web application has to retrieve database from more then two difference sql server.

for example, one from localhost, one from different server ip.

all firewall setting was finished, but i just dont know how to code and use it.

here is my web.config :

[Code]....

this defines only one database in my localhost.but i need to call different connection strings each time i need.

how do i implement this?

View 4 Replies

C# - Is It A Good Practice To Write HTML Using A StringBuilder In Codebehind

Mar 25, 2010

I'm interested to hear from other developers their opinion on an approach that I typically take. I have a web application, asp.net 2.0, c#.

What I usually do to write out drop downs, tables, input controls, etc. is in the code behind use StringBuilder and write out something like sb.Append("

I don't find myself using to many .net controls as I typically write out the html in the code behind. When I want to use jQuery or call JavaScript I just put that function call in my sb.Append tag like sb.Append("td...onblur='fnCallJS()'.

I've gotten pretty comfortable with this approach. For data access I use EntitySpaces.

I'm just kind of curious if this sort of approach is horribly wrong, ok depending on the context, good, time to learn 3.0, etc. I'm interested in learning and was just looking for some input.

Edit

After reading the comments here it sounds like I should take a look at MVC. I've not done that yet. The only hesitancy in doing so is that the existing project is just that, existing. There is a lot of code already done the way I explained and it is hard to imagine what would be involved in changing it, advantages of doing so, and just learning what that would take.

The other thing I'm taking away from the comments is that my code behind should really not include much of the sb.Append code, whereas now it is filled with it in numerous functions. To me it is not messy but that is because I know what each function does and can look at it and see, oh that writes out x, y, and z.

It's not uncommon for me to just have a div on the .aspx part and then build up the .innerHtml of that with the StringBuilder in the code behind.

View 7 Replies

C# - An ImageMap For A Navigation Menu Considered Good Practice?

Feb 2, 2010

Should I use an ImageMap to create a navigation menu?

View 1 Replies

Read Connection String From Web.config

Jan 28, 2011

I called the string in my Data layer

string connectionName = System.Configuration.ConfigurationSettings.AppSettings["Connection"].ToString();

now how could call it in SqlConnection con

View 11 Replies

Where To Store Connection String In Web.Config

Mar 25, 2011

We can store Connection String in Web.config file in two ways One is

<connectionStrings>
<clear/>
<add name="LocalSqlServer"
connectionString="Data Source=(local);Initial Catalog=aspnetdb;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

Other One is

<appSettings>
<add key="ConnectionString"
value="server=localhost;database=Northwind;uid=sa;password=secret;" />
</appSettings>

Now I want to know What is difference between these two approach? Which one is better way? What are their limitations?

UPDATE:Can you explain that <connectionString> has any significant advantage over <appSetting>?

View 5 Replies

Configuration :: Is Possible To Have More Then One Connection String In The Web.config

Oct 19, 2010

I have been preparing for a conversion of an old application to an ASP.NET webapplication at beginning of the year. Generally, the development version of the webapp will also be the webapp that goes into production. We here make "clones" of the database server, assign new name, etc, which is then used for development, training, and so on without any threat of changing data on the real db (sql server 2005). I know it is possible to have more then one connection string in the web.config. My question centers around if there is a simple method for allow multiple connection strings and pick the one that is to be used for dev, production, training, and so on? I originally thought about constructing some type of admin form that the connection string can be selected from.

View 2 Replies

C# - Add And Access Connection String From Web.config?

Nov 18, 2010

I want to add connection string to connect to mysql in web.config and access the same in my code c# how can i do this?

here is my code onclick of a button to connect to database.

protected void Button2_Click(object sender, EventArgs e)
{
String a = DropDownList1.SelectedItem.Value;
String b = DropDownList3.SelectedItem.Value.PadLeft(3, '0');

[Code]....

View 2 Replies

Configuration :: Get Sql Connection String From Web.config?

Dec 15, 2010

I have an app that is a bit old and will eventiall be rewritten but until I get the time it needs to continue to be patched. THe app is desgined broken into three layers (Web, DAL, BLL) The web site uses the DAL.DLL and BLL.DLL and the Website has some dataaccess and the sonnection string is saved in the web.config. For the DAL it is stored in the app.settings. Is there a way for the DAL to use the connection string that is stored in the Web.config even thought it is in DLL for the production site?

View 2 Replies

Which Pattern Most Closely Matches Scenario Detailed And Is It Good Practice

Mar 6, 2011

I have seen a particular pattern a few times over the last few years. In the UI, each new record (e.g., new customers details) is stored on the form without saving to database. This clearly has been done so not clutter the database or cause unnecessary database hits.

While in the UI state, these objects are identified using a Guid. When these are a saved to the database, their associated Guids are not stored. Instead, they are assigned a database Int as their primary key.

The form can cope with a mixure of retrieved items from the database (using Int) as well as those that have not yet been committed (using Guid).

When inspecting the form (using Firebug) to see which key was used, we found a two part delimited combined key had been used. The first part is a guid (an empty guid if drawn from the database) and the second part is the integer (zero is stored if it is not drawn from the database). As one part of the combined key will always uniquely identify a record, it works rather well.

View 3 Replies

Does Anyone Know A Good Practice To Use When Developing For The System.directory Services Class

Jan 31, 2011

I'm trying to create a data access later using System.DirectoryServices. I'd like to use the MVC 2 framework and have all my views be mostly strongly-typed. Does anyone know any good way to this?

For example I started creating a Group Entity:

public class Group
{
public string DistinguishedName { get; set; }
public string GroupName { get; set; }
}

And an abstract interface:

public interface IGroupRepository
{
List<Group> Groups { get; }
}

I am confused about developing the GroupRepository using the system.directory services. Connecting to a SQL database is easy there are examples everywhere but I have no been able to find any using the System.directory sevices in conjunction with a class using MVC. Has anyone tried to do something like this?

View 1 Replies

How To Write Connection String In Web.config File

Jul 30, 2010

how to write connection string in app.config file in vb.net windows application and how to call connection string in forms

View 2 Replies

VS 2008 OleDb Connection String In Web.Config

Aug 14, 2010

How to put an OleDB Connection String in Web.Config I wrote the following code but getting error

Code:
<appSettings>
<add key="ConnectionString"
value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("~/App_Data/AMS.MDB")" />
</appSettings>

Getting error while concatenating a string Data Source=" & Server.MapPath

View 4 Replies

What Is The Correct Format To Add A Db2 Connection String In A Web.config

Jul 28, 2010

would the web.config/machine.config connection string look something like this:-

<connectionStrings>

<add name="DB2dbname" connectionString="Data Source=Db2servername;uid=my userId;pwd=myuseridpawd;mode=SHARE;dbalias=DB2TEST " providerName="System.Data.OleDb.OleDbConnection"/>

View 1 Replies

Finding About Connection String In Web.config File

Jan 15, 2010

why we use connection string in web.config file??? Or what is the benefit of using connection string in web.config file?

View 7 Replies

What's Machine Config - Trying To Keep Each Connection String For Each User

Mar 9, 2010

I am doing a web project in asp.net. Now I am trying to keep each connection string for each user. And the user can decide which server he prefer. How to change this dynamically and where can I store this?. I happen heard about machine.config .Unfortunately i am not familiar with this. Can you just tell what it is and it's use.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved