Sunday, June 19, 2016
So you have a connection string that you want to use in the Web.config file and you want to use in the code behind file. You can do that with a single line of code in your .cs file. Below are the steps to retrieve a connection string in the web.config file programmatically.
1. Make sure you have a connection string in your Web.config file. A connection string looks something like this.
2. Now in the Default.aspx.cs file type in the following in the top of the file, where all the using statements are to use the System.Web.Configuration namespace
3. In the Page_Load method type in the following line
1. Make sure you have a connection string in your Web.config file. A connection string looks something like this.
<connectionStrings> <add name="NorthwindConnectionString" connectionString="Data Source=(local); Initial Catalog=Northwind;Integrated Security=True" providerName="System.Data.SqlClient"/> </connectionStrings>
2. Now in the Default.aspx.cs file type in the following in the top of the file, where all the using statements are to use the System.Web.Configuration namespace
using System.Web.Configuration;Obviously you can use it in any .cs file, the Default.aspx.cs is just an example.
3. In the Page_Load method type in the following line
string connectString = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"]. ConnectionString;To display the connection string on your browser, type the following line
Response.Write(connectString);
Subscribe to:
Post Comments (Atom)
Search This Blog
Tags
Web Development
Linux
Javascript
DATA
CentOS
ASPNET
SQL Server
Cloud Computing
ASP.NET Core
ASP.NET MVC
SQL
Virtualization
AWS
Database
ADO.NET
AngularJS
C#
CSS
EC2
Iaas
System Administrator
Azure
Computer Programming
JQuery
Coding
ASP.NET MVC 5
Entity Framework Core
Web Design
Infrastructure
Networking
Visual Studio
Errors
T-SQL
Ubuntu
Stored Procedures
ACME Bank
Bootstrap
Computer Networking
Entity Framework
Load Balancer
MongoDB
NoSQL
Node.js
Oracle
VirtualBox
Container
Docker
Fedora
Java
Source Control
git
ExpressJS
MySQL
NuGet
Blogger
Blogging
Bower.js
Data Science
JSON
JavaEE
Web Api
DBMS
DevOps
HTML5
MVC
SPA
Storage
github
AJAX
Big Data
Design Pattern
Eclipse IDE
Elastic IP
GIMP
Graphics Design
Heroku
Linux Mint
Postman
R
SSL
Security
Visual Studio Code
ASP.NET MVC 4
CLI
Linux Commands
Powershell
Python
Server
Software Development
Subnets
Telerik
VPC
Windows Server 2016
angular-seed
font-awesome
log4net
servlets
tomcat
AWS CloudWatch
Active Directory
Angular
Blockchain
Collections
Compatibility
Cryptocurrency
DIgital Life
DNS
Downloads
Google Blogger
Google Chrome
Google Fonts
Hadoop
IAM
KnockoutJS
LINQ
Linux Performance
Logging
Mobile-First
Open Source
Prototype
R Programming
Responsive
Route 53
S3
SELinux
Software
Unix
View
Web Forms
WildFly
XML
cshtml
githu
Ace4sure is the website that deals in preparation material for the exam for many years. According to my exposure and research, this is the right platform where you can get exact 220-1001 Exam Dumps.
ReplyDeleteLiên hệ Aivivu, đặt vé máy bay tham khảo
ReplyDeleteVe may bay di My
mua vé máy bay từ mỹ về việt nam hãng eva
vé máy bay giá rẻ từ Canada về Việt Nam
vé máy bay từ nhật về việt nam
vé máy bay incheon hà nội
Vé máy bay từ Đài Loan về VN
chi phi ve may bay cho chuyen gia nuoc ngoai