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

What is Microsoft Excel?
It is an Application which consist of Spread Sheet for creating Document based on requirement
Swati
0 0
5
Hello all, can anyone suggest me how can I get entry as SAP MM Consultant Fresher?
Hi Priya Getting job in SAP itself it's little difficult, so as a fresher it's v difficult to get a job without certification. And another thing is now everything is integrated with HANA and s4 hana...
Priya
0 0
5
I am completed be tech in ECE, then which way is good for me and I am very much interested and in networking.
If you are really interested in networking, don't be in doubt. Start preparing for CCNA, the course content will make you rich in knowledge. Try to practice more in lab that gives you practical exposure...
Anil
0 0
7
is java enough to develop an android application
Android is written in java.but you need to learn about android frame work.But if you know java ,its easy for you to learn android
Kalyan

I'm just pursuing MCA & I'm in last year. I want a good career in animation and graphics so what do I have to learn and also how do I learn that and also tell me at where I will get 6th month internship training regarding mentioned programs?

Man, you must be overwhelmed by all the answers. I would recommend you do NOTHING BUT RESEARCH right now. Everyone has their own opinion, but you need to decide what you want to do and why. Now comes the...
Sachin

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

Ask a Question

Related Lessons

Excel Keyboard Shortcuts
Our day to day work involves excel and to complete our work fast we should have adequate knowledge of keyboard shortcuts. I am going to give you simple but useful tip which will helps you to navigate excel...
G

SAP Training
Dear Candidate, Please accept my greetings, SAP, It stands for Systems Applications and Products in Data processing. It’s German software and is being implemented in all companies from SME’s...
N

Netbusiness Solutions

0 0
0

Best way to learn any software Course
Hi First conform whether you are learning from a real time consultant. Get some Case Studies from the consultant and try to complete with the help of google not with consultant. Because in real time same situation will arise. Thank you

What are the basic differences between SAS and R languages?
SAS SAS is the integrated system of software solutions, and it is the leader in the data analytics field. This software has a lot of features like good GUI and others to provide excellent technical...

The Importance Of IT Service Management
Does artificial intelligence fall under the ambit of IT services? Yes, so long they are used for IT related projects and programs. Automation is again big time in the software industry. Check out 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