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

Hi All, I have completed B.com,MBA F&M and SAP MM Consultant level training ,5 yrs working experince into SAP MM End user in MNC pune but there is no job for SAP MM Fresher and sap mm end user.
Please suggest to another  Non - SAP Course or what should i do next?

Hi, Priya. As I went through your point, I assume that you have good exposure to Accounts and its access to a few software. You need not worry. The only thing I would suggest you go for Tally Authorized...
Priya

Who is the best tutor to learn togaf?

Dileep TOGAF trainer at Ashok Nagar, Mumbai Amit Midha TOGAF trainer at Sector 56, Gurgaon.
Emaam
0 0
5
How is C++ language used nowadays?
C++ is a fast and strongly-typed programming language which makes it an ideal choice for developing operating systems. Mac OS X has large amounts written in C++. Most of the software from Microsoft like...
Arumugam
0 0
5
How to become an expert or tutor in UrbanPro ?
You need to register as tutor, and you can choose which skill you expert I mean which you want to teach and give all the information.
Jenil

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

Ask a Question

Related Lessons


VBA Tip: Print Random Numbers In A Selected Range
Let’s say you want to print some random numbers in a selected range then you can use below Macro. Sub Print_Randomnumbers() Dim myrng As Range For Each myrng In Selection myrng.Value = Application.WorksheetFunction.Int(Rnd...

Database Origins
The need for a database originates from the fact that computers are dumb devices having batman like abilities which can be smartly be utilised by feeding it the right content. That is, for example, consider...
M

Essential SQL Tips For Developers And For MS SQL DBA
10 Essential SQL Tips for Developers: SQL is yet another essential language for developers wishing to create data-driven websites. However, many developers are unfamiliar with various aspects of SQL;...

Built-in Functions In Excel
i. Built In Functions: MS Excel has many built in functions, which we can use in our formula. To see all the functions by category, choose Formulas Tab » Insert Function. Then Insert function Dialog...

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