UrbanPro

Learn IT Courses from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Hi,

I have asp.net project with sql connection.I want connect database with asp.net and run the project and web config file there

Asked by Last Modified  

Follow 13
Answer

Please enter your answer

Computer Teaching 1.5yr, Mathematics Teaching 1yr Excel Teaching 6Month

In web.config: <connectionStrings> <add name="ConnectionString" connectionString="Data Source=192.168.1.25;Initial Catalog=Login;Persist Security Info=True;User ID=sa;Password=example.com" providerName="System.Data.SqlClient" /> </connectionStrings>In Class.cs public static string ConnectionString{...
read more

In web.config: <connectionStrings> <add name="ConnectionString" connectionString="Data Source=192.168.1.25;Initial Catalog=Login;Persist Security Info=True;User ID=sa;Password=example.com" providerName="System.Data.SqlClient" /> </connectionStrings>In Class.cs public static string ConnectionString{ get{ return ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;} set{}

read less
Comments

IT Professional with 8+ years of teaching experience

Put this in Web configuration file as: <connectionStrings> <add name="yourconnectinstringName" connectionString="Data Source= DatabaseServerName; Integrated Security=true;Initial Catalog= YourDatabaseName; uid=YourUserName; Password=yourpassword; " providerName="System. Data. SqlClient" />...
read more

Put this in Web configuration file as: <connectionStrings> <add name="yourconnectinstringName" connectionString="Data Source= DatabaseServerName; Integrated Security=true;Initial Catalog= YourDatabaseName; uid=YourUserName; Password=yourpassword; " providerName="System. Data. SqlClient" /></connectionStrings>

read less
Comments

IT Professional Trainer with 10 years of experience in IT Industry

<connectionStrings> <add name="ConnStringDb1" connectionString="Data Source=localhost;Initial Catalog=YourDataBaseName;Integrated Security=True;" providerName="System.Data.SqlClient" /> </connectionStrings>
Comments

RPA Developer with 4 years of experience

<connectionStrings> <add name="ReviewsConnectionString" connectionString="Data Source=serverName; Initial Catalog=databaseName; Persist Security Info=True; User ID=username; Password=password" providerName="System.Data.SqlClient" /> </connectionStrings>
Comments

IT professional with 5 years experience

<connectionStrings> <add name="yourconnectinstringName" connectionString="Data Source= DatabaseServerName; Integrated Security=true;Initial Catalog= YourDatabaseName; uid=YourUserName; Password=yourpassword; " providerName="System. Data. SqlClient" /> </connectionStrings>
read more
  1. <connectionStrings>
  2. <add name="yourconnectinstringName" connectionString="Data Source= DatabaseServerName; Integrated Security=true;Initial Catalog= YourDatabaseName; uid=YourUserName; Password=yourpassword; " providerName="System. Data. SqlClient" />
  3. </connectionStrings>
read less
Comments

IT professionals instructor with experience of AI

<connectionStrings> <add name="yourconnectinstringName" connectionString="Data Source= DatabaseServerName; Integrated Security=true;Initial Catalog= YourDatabaseName; uid=YourUserName; Password=yourpassword; " providerName="System.Data.SqlClient" /> </connectionStrings>...
read more
  1. <connectionStrings>  
  2.     <add name="yourconnectinstringName" connectionString="Data Source= DatabaseServerName; Integrated Security=true;Initial Catalog= YourDatabaseName; uid=YourUserName; Password=yourpassword; " providerName="System.Data.SqlClient" />   
  3. </connectionStrings>  
read less
Comments

"Where Mathematics Meets The Elegance"

<connectionStrings> <add name="yourconnectinstringName" connectionString="Data Source= DatabaseServerName; Integrated Security=true;Initial Catalog= YourDatabaseName; uid=YourUserName; Password=yourpassword; " providerName="System.Data.SqlClient" /> </connectionStrings>
read more

<connectionStrings>       <add name="yourconnectinstringName" connectionString="Data Source= DatabaseServerName; Integrated Security=true;Initial Catalog= YourDatabaseName; uid=YourUserName; Password=yourpassword; " providerName="System.Data.SqlClient" />    </connectionStrings> 

read less
Comments

Research Professional with 12 Years of Experience in Computer Programming and Research Tools

'Connectionstring' is the variable to use the connection string in any class of the .net. ip_address_of_server : represents the ip of the server databasename : database name username : name of the database user password : password of the database associated with the user Use belo code in web.config file...
read more

'Connectionstring' is the variable to use the connection string in any class of the .net.

ip_address_of_server : represents the ip of the server

databasename : database name

username : name of the database user

password : password of the database associated with the user

Use belo code in web.config file 

<appSettings>
<add key="connectionstring" value="server=ip_address_of_server;database=databasename;uid=username;pwd=password"/>
</appSettings>

read less
Comments

IT Proffesional with 4 years of expo in development and support

namespace DemoApplication { public partial class Demo System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string connetionString; SqlConnection cnn; connetionString = @"Data Source=WIN-50GP30FGO75;Initial Catalog=Demodb ;User ID=sa;Password=demol23"; cnn...
read more
namespace DemoApplication
{  
	public partial class Demo  System.Web.UI.Page  
    {  
	  protected void Page_Load(object sender, EventArgs e)  
	  {  
		string connetionString;
		SqlConnection cnn;
            
		connetionString = @"Data Source=WIN-50GP30FGO75;Initial Catalog=Demodb ;User ID=sa;Password=demol23";
			
		cnn = new SqlConnection(connetionString);
			
		cnn.Open();  
			
		Response.Write("Connection MAde");    
		conn.Close();  
			
	  }
	}
}
read less
Comments

IT Professional Trainer with 10 years of experience in IT Industry

After opening the web.config file in application, add sample db connection in connectionStrings section like this: <connectionStrings> <add name="yourconnectinstringName" connectionString="Data Source= DatabaseServerName; Integrated Security=true;Initial Catalog= YourDatabaseName;...
read more

After opening the web.config file in application, add sample db connection in connectionStrings section like this:

 
  1. <connectionStrings>  
  2.     <add name="yourconnectinstringName" connectionString="Data Source= DatabaseServerName; Integrated Security=true;Initial Catalog= YourDatabaseName; uid=YourUserName; Password=yourpassword; " providerName="System.Data.SqlClient" />   
  3. </connectionStrings>  

Declaring connectionStrings in web.config file:

 
  1. <connectionStrings>  
  2.     <add name="dbconnection" connectionString="Data Source=Soumalya;Integrated Security=true;Initial Catalog=MySampleDB" providerName="System.Data.SqlClient" />   
  3. </connectionStrings>  
There is no need of username and password to access the database server.
 

Now, write the code to get the connection string from web.config file in our codebehind file. Add the following namespace in codebehind file.

using System.Configuration;


This namespace is used to get configuration section details from web.config file.

C# code

 
  1. using System;  
  2. using System.Data.SqlClient;  
  3. using System.Configuration;  
  4. public partial class _Default: System.Web.UI.Page {  
  5.     protected void Page_Load(object sender, EventArgs e) {  
  6.         //Get connection string from web.config file  
  7.         string strcon = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;  
  8.         //create new sqlconnection and connection to database by using connection string from web.config file  
  9.         SqlConnection con = new SqlConnection(strcon);  
  10.         con.Open();  
  11.     }  
  12. }
read less
Comments

View 48 more Answers

Related Questions

How are portions of a program disabled in demo versions?
By inserting comments in the program Single line comment denoted by // Multi line comment denoted by /* */
Akhilesh
0 0
5
Does a civil engineer need to learn the C language?
C language is a common subject in the first year of engineering irrespective of the branch. It may not be helpful for your civil engineering career but you definitely need to pass for B.Tech graduation.
Sandeep
0 0
5
Hi Guys!! Please help me. Am going to take a course. Please suggest me which is best? 1. Informatica (or) Tableau? 2.which subject is more easy to learn? 3.Which is having less coding? 4.which is having more opportunities? TIA
Hi Ajith, I would suggest Informatica as having less coding and 90% is graphical interface. 99% IT companies , these days using Informatica as a ETL tool and it is in high demand these days. you can contact me any time for demo.
Deleted
My name is Rajesh , working as a Recruiter from past 6 years and thought to change my career into software (development / admin/ testing ) am seeking for some suggestion which technology I need to learn ? Any job after training ? Or where I can get job within 3 months after finishing my training programme- your advices are highly appreciated
Mr rajesh if you want to enter in to software Choose SAP BW AND SAP HANA because BW and HANA rules the all other erp tools next 50 years.it provides rubust reporting tools for quicker decesion of business It very easy to learn
Rajesh
1 0
6

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

What To Learn For A Python Programming Beginner?
For a beginner of any programming language, they are confused what to study initially and up to what depth? For a person to study the basics of Python programming, include the reserved keywords, identifiers,...

What is a SQL join?
A SQL join is a Structured Query Language (SQL) instruction to combine data from two sets of data (e.g. two tables). Before we dive into the details of a SQL join, let’s briefly discuss what SQL...

Tips - How to put PivotTable Field List back at its Original Position?
Have You ever struggled to put PivotTable Field List back at its Original Position?*Original Position - right-side of the worksheet, as highlighted in the following picture: If Your answer is Yes, You...


Create A Dolphin In The Deep Blue Ocean
In this tutorial, we’ll be learning how to create a dolphin in the deep blue ocean using Adobe Illustrator.You’ll start by creating the deep blue ocean with the help of the Rectangle Tool and...

Recommended Articles

Almost all of us, inside the pocket, bag or on the table have a mobile phone, out of which 90% of us have a smartphone. The technology is advancing rapidly. When it comes to mobile phones, people today want much more than just making phone calls and playing games on the go. People now want instant access to all their business...

Read full article >

Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...

Read full article >

Software Development has been one of the most popular career trends since years. The reason behind this is the fact that software are being used almost everywhere today.  In all of our lives, from the morning’s alarm clock to the coffee maker, car, mobile phone, computer, ATM and in almost everything we use in our daily...

Read full article >

Information technology consultancy or Information technology consulting is a specialized field in which one can set their focus on providing advisory services to business firms on finding ways to use innovations in information technology to further their business and meet the objectives of the business. Not only does...

Read full article >

Looking for IT Courses ?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for IT Courses Classes?

The best tutors for IT Courses Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn IT Courses with the Best Tutors

The best Tutors for IT Courses Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more