Literal, hard-coded string found in code
Publicado por Wendy Martinez (1 intervención) el 07/10/2009 18:48:59
Hola a todos.
Hj estado buscando la solucion a este probelma y la verdad ya no se como hacerle, mira estoy programando en c# utilizando Visual Studio 2005 y estoy usando una herramienta de inspección que se llama DevPartner que es para mejorar la estructura de mi código y me detecta el siguiente problema:
Literal, hard-coded string found in code
Trigger: Detected Literal, hard-coded, string in code [Occurrences: 1]
Original Source Line: comando.Parameters["@idproyecto"].Value =Idproyecto;
y me brinda una opción para repararlo:
Repair
Add a resource file to your project and place this literal string in this resource file. The resource file should contain the literal hard-coded string values, bitmap (.bmp), icon (.ico), or cursor images (.cur) images and other data. Use the ResourceManager class to retrieve the information such as literal strings from the resource file.
The following example code uses the ResourceManager class to retrieve a string literal:
Visual C# .NET example:
ResourceManager rm = new ResourceManager("MyLocalizedData", this.GetType().Assembly);
string foo = rm.GetString("string1");
pero la verdad es que no como aplicarla a mi código.Si pudiera alguien ayudarme se los agradeceria mucho, le envio la parte del codigo de mi proyecto.
public void cargaDescripcion2(Label descrip2)
{
sqlcon = new SqlConnection(cadena);
sqlcon.Open();
string query = "Select descrip from [dbo].[Tbl.Proyecto] where Id_Proyecto=@idproyecto";
SqlCommand comando = new SqlCommand(query, sqlcon);
comando.Parameters.Add("@idproyecto", SqlDbType.Int);
comando.Parameters["@idproyecto"].Value =Idproyecto;
SqlDataReader infMicro = comando.ExecuteReader();
if (infMicro.HasRows)
{
infMicro.Read();
descrip2.Text = infMicro["Descripcion2"].ToString();
}
infMicro.Close();
sqlcon.Close();
comando.Connection.Close();
}
Hj estado buscando la solucion a este probelma y la verdad ya no se como hacerle, mira estoy programando en c# utilizando Visual Studio 2005 y estoy usando una herramienta de inspección que se llama DevPartner que es para mejorar la estructura de mi código y me detecta el siguiente problema:
Literal, hard-coded string found in code
Trigger: Detected Literal, hard-coded, string in code [Occurrences: 1]
Original Source Line: comando.Parameters["@idproyecto"].Value =Idproyecto;
y me brinda una opción para repararlo:
Repair
Add a resource file to your project and place this literal string in this resource file. The resource file should contain the literal hard-coded string values, bitmap (.bmp), icon (.ico), or cursor images (.cur) images and other data. Use the ResourceManager class to retrieve the information such as literal strings from the resource file.
The following example code uses the ResourceManager class to retrieve a string literal:
Visual C# .NET example:
ResourceManager rm = new ResourceManager("MyLocalizedData", this.GetType().Assembly);
string foo = rm.GetString("string1");
pero la verdad es que no como aplicarla a mi código.Si pudiera alguien ayudarme se los agradeceria mucho, le envio la parte del codigo de mi proyecto.
public void cargaDescripcion2(Label descrip2)
{
sqlcon = new SqlConnection(cadena);
sqlcon.Open();
string query = "Select descrip from [dbo].[Tbl.Proyecto] where Id_Proyecto=@idproyecto";
SqlCommand comando = new SqlCommand(query, sqlcon);
comando.Parameters.Add("@idproyecto", SqlDbType.Int);
comando.Parameters["@idproyecto"].Value =Idproyecto;
SqlDataReader infMicro = comando.ExecuteReader();
if (infMicro.HasRows)
{
infMicro.Read();
descrip2.Text = infMicro["Descripcion2"].ToString();
}
infMicro.Close();
sqlcon.Close();
comando.Connection.Close();
}
Valora esta pregunta


0