Opening connection to db

J

John

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
 
I

Iaml

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
 
P

Peter Bromberg [C# MVP]

SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings["Events"].ConnectionString);
conn.Open();
--Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top