Error in web.config file and dataaccess

hi Experts,

                I am using, C# , SQL SERVER. In my web.config file I am using ProviderName= "System.Data.SqlClient", but in my data access i am using dbProvider, when i execute i got the error. I have attached screen shot for your review. I guess the error is in between web.config and my dataAccess. Please let me know.


    <add name="BalloonShopConnection" connectionString="server=TAPAN-PC;Database=BallonShop;User=ballonshop;Password=ecommerce" ProviderName="System.Data.SqlClient"/>



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.Common;

/// <summary>
/// Class contains generic data access functionality to be accessed from the businesstier
/// </summary>
public static class GenericDataAccess
    //static constructor
    static GenericDataAccess()

    //Execute a command and returns the results as a dataTable object
    public static DataTable ExecuteSelectCommand(DbCommand command )
        //The DataTable to be returned

        DataTable table;

        // Execute the command,making sure the connection gets closed in the end
            //Open the data connection
            //Execute the command and save the results in a DataTable
            DbDataReader reader = command.ExecuteReader();

            table = new DataTable();

            //Close the connection
        catch (Exception ex)
            //close the connection
        return table;

    //Create and prepares a new Dbcommand object on a new connection

    public static DbCommand CreateCommand()
        //obtain the database provider name;

        string dataProviderName = BalloonShopConfiguration.DbProviderName;

        //Obtain the database connection string
        string connectionString = BalloonShopConfiguration.DbConnectionString;
        //Create a new data Provider Factroy
        DbProviderFactory factory= DbProviderFactories.GetFactory(dataProviderName);

        // Obtain a database-specific connection object
        DbConnection conn = factory.CreateConnection();

        //set the connection string
        conn.ConnectionString = connectionString;

        //create a database specific command object
        DbCommand comm = conn.CreateCommand();

        // Set the command type to stored procecures
        comm.CommandType = CommandType.StoredProcedure;

        //Return the initialized command object
        return comm;


LVL 22
Tapan PattanaikSenior EngineerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Alfred A.Connect With a Mentor Commented:

What is the exact error displayed if you inspect ex.Message, ex.Source, and ex.StackTrace?  Can you provide that information?
Tapan PattanaikSenior EngineerAuthor Commented:
When i build the solution (F6). it tells  build succeed, but when i press F5 ,it redirects to the  "App_Code\GenericDataAccess.cs" file. Screen shot of  which i was attached previously and i was also posted full code of that page  in my question.

In the web browser i have seen this error. which i have attached screen shot below for your review.

<if you want to check my ConnectionString , you can check in my question which i have posted first.>

tapan Pattanaik.
Tapan PattanaikSenior EngineerAuthor Commented:
Please check the exact error message.

Tapan PattanaikSenior EngineerAuthor Commented:
From StackTrace i found  the error was in connection string. I was writing wrong " ProviderName" instead of "providerName".

All Courses

From novice to tech pro — start learning today.