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 are the career options available after completing Corel Draw
Frankly telling you only doing a course of Corel Draw wont be feasible. You can do a Graphic Designing Course which would include Photoshop, Adobe Illustrator & In Design as well. This is help you for getting a good job as a Graphic Designer.
Mallik
0 0
9
Is C#, C++, Python, or JS better for game development?
All languages good for gamjng. But you can make 3d games in c# uaing unity software and it's very very interesting to work on it.
Mohit
0 0
6
I am currently having experiance in Mainframe operation support. Is there any possibility to change my carrier into SAP?
Dear Vinoth, You have experience in MF operation support. it means you have technical background hence go for ABAP contact us for more details www.kbmtechnosoft.com About Trainer: Our trainer are...
Vinoth
0 0
9
How can i improve my enquirers on SAP Security & GRC Access Control Online training..?
Create your profile as a trainer in urbanpro, post your training's, start providing online or offline training's.
Yaga
0 0
5

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

Ask a Question

Related Lessons

9 Cybersecurity Trends & Predictions For 2018
The unpleasant cyber attacks of 2017 are still fresh in the minds of the people. To mention a few, they are Wanna Cry, Not Petya, Equifax, and etc. Evidently, the 'Cybersecurity' term which was known...


Living with Concepts
Always it is a complain from many students that they do not remember concepts taught and learnt as time progresses. Even exceptional students also falls pray to effect of time fading. The tip which i generally...
B

Babu T

0 0
0

Swift Constants
Objective C Provides a way to declare constant using Const keyword.In Objective C we often use #define for declaring a macro.Swift the way to declare constants is different from objective C. Let is used...

Read Your Gmail Emails Using PHP and IMAP
Hello Friends ,Recently I have worked on drip email campaign project for that I need to read emails using PHP From the gmail inbox. Here is the simple example for Read emails from the gmail: To start...

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