473,395 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Opening connection to db

Hi

I have the following connection info in my web.config file;

<connectionStrings>
<add
providerName="System.Data.SqlClient" connectionString="Data
Source=MySQLServer.net;Initial Catalog=&quot;MyDB&quot;;Persist Security
Info=True;User ID=&quot;UID&quot;;Password=MyPassword" name="Events" />
</connectionStrings>

How can I open a connection to this db in my code?

Thanks

Regards
Jun 1 '08 #1
2 1305
On May 31, 11:42 pm, "John" <i...@nospam.infovis.co.ukwrote:
Hi

I have the following connection info in my web.config file;

<connectionStrings>
<add
providerName="System.Data.SqlClient" connectionString="Data
Source=MySQLServer.net;Initial Catalog=&quot;MyDB&quot;;Persist Security
Info=True;User ID=&quot;UID&quot;;Password=MyPassword" name="Events" />
</connectionStrings>

How can I open a connection to this db in my code?

Thanks

Regards
This following article will help you:

http://msdn.microsoft.com/en-us/library/ms998300.aspx

Jun 1 '08 #2
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrin gs["Events"].ConnectionString);
conn.Open();
--Peter
"John" <in**@nospam.infovis.co.ukwrote in message
news:uF**************@TK2MSFTNGP04.phx.gbl...
Hi

I have the following connection info in my web.config file;

<connectionStrings>
<add
providerName="System.Data.SqlClient" connectionString="Data
Source=MySQLServer.net;Initial Catalog=&quot;MyDB&quot;;Persist Security
Info=True;User ID=&quot;UID&quot;;Password=MyPassword" name="Events" />
</connectionStrings>

How can I open a connection to this db in my code?

Thanks

Regards

Jun 1 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Anja | last post by:
I have installed the new Visual Studio 2003 and implemented the FolderBrowserDialog. Everything works fine, if I open the FolderBrowserDialog before opening a Database Connection. If I open...
0
by: John Winterbottom | last post by:
Does anyone know if this is possible? We are running Access XP with Windows XP Prof.. We have an ADP file we are using to print custom reports for a client. It's opened and conntrolled through...
3
by: Giuseppe D'Elia | last post by:
Hi there, I got a problem using an MS Access database through ASP.NET. After updating my system from .NET Framework 1.0 to 1.1, my existing application gives me the following error when...
5
by: Burton Roberts | last post by:
When using ASP.NET and an OleDBConnection control I get this error on CNN.Open: "The Microsoft Jet database engine cannot open the file 'C:\A2K\Backups\EdsBe2K.mdb'. It is already opened...
5
by: Daves | last post by:
is it a good or bad practise to use the session_start & session_end for opening & closing the database connection? I'd thought that on powerful servers today the time the connection is kept locked...
1
by: Bennie Tilma | last post by:
I'm having trouble with opening the python IDLE-program. When I try to start it, it gives an errormessage wich states that it can not make a connection, possibly because of a firewall. However,...
2
by: Macca | last post by:
Hi, I am writing an app that will have a socket server to listen for and process data from 20+ clients. These clients will send data aproximately every 400-500ms. I was wondering if it is...
7
by: Martien van Wanrooij | last post by:
I have been faced a couple of times with the situation that I wanted to write a script and was worried about a too frequent opening and closing mysql connections. To give some examples: 1)I...
1
by: LeAnne | last post by:
my application polls a database every X seconds. Some times X = 0.5 seconds (500 milli seconds) The way the code has been written, the SQL connection is opened & closed during every poll. Is...
4
by: kessa | last post by:
Hi Guys, I've recently had a problem with my site displaying a "system resources exceeded" error message ... and whilst searching this site for a solution (which I think I've now found) I came...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.