1. Este site usa cookies. Ao continuar a usar este site está a concordar com o nosso uso de cookies. Saber Mais.

ExecuteReader: CommandText property has not been initialized c#

Discussão em 'Web Development' iniciada por alfinete, 21 de Janeiro de 2009. (Respostas: 2; Visualizações: 1616)

  1. alfinete

    alfinete Power Member

    quanto a store aqui puchada funciona nas devidas condições e os parametros estão a ser chamados pela ordem correcta

    estou em asp.net c# com sql server


    Código:
     public DataTable ENBReportMapFormationByParametersSEL(DateTime m_BeginDate, DateTime m_EndDate, int m_DCIDTematicZone, int m_DCIDCourse, int m_DistrictID, int m_CountyID, string m_Status, string m_EntityID, int m_TrainerID, string m_CourseType, string m_Cost, int m_FCID, string m_AskNBR, string m_Payment, string m_ReportType, string m_User)
            {
                DataTable oDT = new DataTable("ENBStats");
              
                switch (m_DBInUse)
                {
                    case "MSACCESS":
                        break;
                    case "SQL2K":
                        try
                        {
                            ResourceManager oRM = new ResourceManager(typeof(Resources.SQL2KENBStats));
                            SqlParameter[] oParams = new SqlParameter[14];
    
                            
                            sqlConn = new SqlConnection(ConnectionString);
                            sqlConn.Open();
    
                            SqlCommand sqlComm = new SqlCommand(oRM.GetString("spENBReportMapFormationCheckBoxByParametersSEL"), sqlConn);
                            sqlComm.CommandTimeout = 120;
                            sqlComm.CommandType = CommandType.StoredProcedure;
                            
    
                            oParams[0] = new SqlParameter("@REPORTTYPE", SqlDbType.NVarChar);
                            if (!string.IsNullOrEmpty(m_ReportType))
                            {
                                oParams[0].Value = m_ReportType;
                            }
                            else
                            {
                                oParams[0].Value = "1";
                            }
    
                            oParams[1] = new SqlParameter("@DTBEGIN", SqlDbType.DateTime);
                            if (m_BeginDate != DateTime.MinValue)
                            {
                                oParams[1].Value = m_BeginDate.ToString("yyyy-MM-dd");
                            }
                            else
                            {
                                oParams[1].Value = System.DBNull.Value;
                            }
    
                            oParams[2] = new SqlParameter("@DTEND", SqlDbType.DateTime);
                            if (m_EndDate != DateTime.MinValue)
                            {
                                oParams[2].Value = m_EndDate.ToString("yyyy-MM-dd");
                            }
                            else
                            {
                                oParams[2].Value = System.DBNull.Value;
                            }
    
    
                            oParams[3] = new SqlParameter("@AskNBR", SqlDbType.VarChar);
                            if (!string.IsNullOrEmpty(m_AskNBR))
                            {
                                oParams[3].Value = m_AskNBR;
                            }
                            else
                            {
                                oParams[3].Value = System.DBNull.Value;
                            }
    
    
                            oParams[4] = new SqlParameter("@COSTTYPE", SqlDbType.Int);
                            if (!string.IsNullOrEmpty(m_Cost))
                            {
                                oParams[4].Value = m_Cost;
                            }
                            else
                            {
                                oParams[4].Value = System.DBNull.Value;
                            }
    
                            oParams[5] = new SqlParameter("@STATUS", SqlDbType.NVarChar);
                            if (!string.IsNullOrEmpty(m_Status))
                            {
                                oParams[5].Value = m_Status;
                            }
                            else
                            {
                                oParams[5].Value = System.DBNull.Value;
                            }
    
    
                            oParams[6] = new SqlParameter("@FormationLocalID", SqlDbType.Int);
                            if (m_FCID != -1)
                            {
                                oParams[6].Value = m_FCID;
                            }
                            else
                            {
                                oParams[6].Value = System.DBNull.Value;
                            }
    
    
                            oParams[7] = new SqlParameter("@DISTRICTID", SqlDbType.Int);
                            if (m_DistrictID != -1)
                            {
                                oParams[7].Value = m_DistrictID;
                            }
                            else
                            {
                                oParams[7].Value = System.DBNull.Value;
                            }
    
                            oParams[8] = new SqlParameter("@COUNTYID", SqlDbType.Int);
                            if (m_CountyID != -1)
                            {
                                oParams[8].Value = m_CountyID;
                            }
                            else
                            {
                                oParams[8].Value = System.DBNull.Value;
                            }
    
    
                            oParams[9] = new SqlParameter("@DCIDTEMATICZONE", SqlDbType.Int);
                            if (m_DCIDTematicZone != -1)
                            {
                                oParams[9].Value = m_DCIDTematicZone;
                            }
                            else
                            {
                                oParams[9].Value = System.DBNull.Value;
                            }
    
    
                            oParams[10] = new SqlParameter("@COURSETYPE", SqlDbType.VarChar);
                            if (!string.IsNullOrEmpty(m_CourseType))
                            {
                                oParams[10].Value = m_CourseType;
                            }
                            else
                            {
                                oParams[10].Value = System.DBNull.Value;
                            }
    
    
                            oParams[11] = new SqlParameter("@ENTITYID", SqlDbType.VarChar) ;
                            if (!string.IsNullOrEmpty(m_EntityID) )
                            {
                                oParams[11].Value = m_EntityID;
                            }
                            else
                            {
                                oParams[11].Value = System.DBNull.Value;
                            }
    
                            oParams[12] = new SqlParameter("@TRAINERID", SqlDbType.Int);
                            if (m_TrainerID != -1)
                            {
                                oParams[12].Value = m_TrainerID;
                            }
                            else
                            {
                                oParams[12].Value = System.DBNull.Value;
                            }
    
                            oParams[13] = new SqlParameter("@SYSTEMUSERNAME", SqlDbType.VarChar);
                            if (!string.IsNullOrEmpty(m_User))
                            {
                                oParams[13].Value = m_User;
                            }
                            else
                            {
                                oParams[13].Value = "hl";
                            }
    
                            if (oParams != null)
                            {
                                foreach (SqlParameter parm in oParams)
                                    sqlComm.Parameters.Add(parm);
                            }
    
                            SqlDataAdapter adapter = new SqlDataAdapter(sqlComm);
    
                            [B][COLOR=Red]adapter.Fill(oDT); [/COLOR][/B]
                            //SqlHelper.CommandTimeout = 500;
                            //oDT = SqlHelper.ExecuteDataset(m_ConnectionString, oRM.GetString("spENBReportMapFormationByParametersSEL"), oParams).Tables[0];
                            sqlConn.Close(); 
                            oRM = null;
                        }
                        catch (Exception Err)
                        {
                            m_Error = Err.Message.ToString();
                        }
                        break;
                }
                return oDT;
            }
    
    agradecioa que me dessem um help

    esta a dar este erro

    ExecuteReader: CommandText property has not been initialized na linha a vermelho
     
  2. SoundSurfer

    SoundSurfer Power Member

    verifica se isto:

    Código:
    oRM.GetString("spENBReportMapFormationCheckBoxByParametersSEL")
    Não está a devolver null ou string vazia.
     
  3. alfinete

    alfinete Power Member

    quem sabe sabe, foi mesmo isso , não tinha o nome da store nos resources ..


    obrigada
     

Partilhar esta Página