How to connect SQL Server in WCF services

Posted on 2012-09-17
Last Modified: 2012-09-19
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.
Question by:5281
    LVL 83

    Expert Comment

    For config, use ConfigurationManager class

    For DB, same as any other application type. Create a connection and execute SQL.

    Author Comment

    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.
    LVL 83

    Accepted Solution

    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now