• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 953
  • Last Modified:

How to connect SQL Server in WCF services

How to connect to SQL Server in WCF services?  How to call the connection string which is in web.config file?

I need sample code for calling(accessing) database in WCF services and sample code for web.config connection string.  


Thank you.
0
5281
Asked:
5281
  • 2
1 Solution
 
CodeCruiserCommented:
For config, use ConfigurationManager class

http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.appsettings.aspx

For DB, same as any other application type. Create a connection and execute SQL.
0
 
5281Author Commented:
Could you give me a sample code in VB.Net using ConfigurationManager to connect database and output data, and sample code for connection string in web.config.
0
 
CodeCruiserCommented:
ConfigurationManager is for the web.config and example is in the link above.

Example of reading data from sql server is at the bottom of this page

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspx
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now