Skip to content

Error on class file

Joan Hache

Asked Jun 17, 2008, 5:52 PM EDT4 answers
Share
LinkedInX

Hello there:

I've just wrote a class file and it gives me the error: "The name 'campo' does not exists in the current content"

Can somebody give a hand and tell me how can I correct this problem, here is the class file:

PowerShell
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.Adapters;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class TipoNegocioSQL : System.Web.UI.Page
{
protected void Page_Load(Object sender, EventArgs e)
{
string Conexion = "server=server;Integrated Security=True;database=mydatabase;";
SqlConnection cn = new
SqlConnection(Conexion);
cn.Open();

System.Data.SqlClient.SqlCommand cmd = new
System.Data.SqlClient.SqlCommand();
cmd.Connection = cn;
cmd.CommandText = "SELECT identificacion from mytable";

SqlDataReader dr;
dr = cmd.ExecuteReader();

while ( dr.Read() )

{
campo.Text  += dr["identification"];
}

}
}

 

Thank you very much

4 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Niradhip Chakraborty
    0
    Are you using any control(id as campo)? Please check out whether it is a server control or not?May be campo(control) doesn't exist in your appliication.
    0
  • 0

    James, I'm using:

    <body>


    <form method="post" runat="server" id="form1">
    <asp: Hyperlink id = "campo" runat="server"/>
    </form>

    </body>

    In a aspx file which inherits the class I wrote

    0
  • Niradhip Chakraborty
    0
    Your code:
    <asp: Hyperlink id = "campo" runat="server"/>
    modified code :
    <asp:HyperLink ID="campo" runat="server"></asp:HyperLink>
    0
  • 0
    After the code change I get the same results
    0