• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 969
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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