locked
Simple error connection string null reference RRS feed

  • Question

  • User2034657745 posted

     It is failing on

    SqlHelper.ExecuteNonQuery(System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString

     

      public static string GetAboutMeName(string sUserID, string connectionString)
            {

                SqlParameter[] parameters = new SqlParameter[2];
             
                parameters[0] = new SqlParameter("@sUserID", SqlDbType.VarChar, 50);
                parameters[0].Value = sUserID;

                parameters[1] = new SqlParameter("@sResult", SqlDbType.NVarChar, 1000);
                parameters[1].Direction = ParameterDirection.Output;

                // Execute the stored procedure
                SqlHelper.ExecuteNonQuery(System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString, CommandType.StoredProcedure, "sprGetAboutMeName", parameters);
                // create a string array of return values and assign values returned from stored procedure
                string[] arReturnParms = new string[1];
                arReturnParms[0] = parameters[1].Value.ToString();

                return arReturnParms[0];

            }

    Monday, January 25, 2010 4:22 AM

All replies

  • User-126244515 posted

    Does connectionString exist in the configuration file? 

    Monday, January 25, 2010 4:45 AM
  • User236141260 posted

    Please post description of error.

    Monday, January 25, 2010 4:46 AM
  • User-1171043462 posted

    Check whether

    1. You have a key present in connection strings section

    2. check the key name whether it is equal to connectionString or is something else

    Monday, January 25, 2010 5:01 AM
  • User-624088818 posted

    I believe that System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString returning null value.

    Please check the key and value from the web.config file.

    Eg:System.Configuration.ConfigurationManager.AppSettings["connectionString"].ToString();

    Tuesday, February 16, 2010 10:37 AM