Gracias
Nombre del Error: Object reference not set to an instance of an object
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
ASP.i_s_c_iscalamilla_proyecto_final_borraralgo_as px.BORRAR(Object sender, EventArgs e) +163
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
<Html>
<%@ PAGE LANGUAGE=C# %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<FORM RUNAT=SERVER>
CLAVE A BORRAR<ASP:TEXTBOX ID=CLAVE RUNAT=SERVER/>
<ASP:BUTTON ONCLICK=EVENTO1 TEXT=Desplegar RUNAT=SERVER /><BR>
<ASP:BUTTON ONCLICK=BORRAR TEXT=BORRAR RUNAT=SERVER /><BR>
<ASP:DATAGRID ID=TABLAGRID RUNAT=SERVER
Width=400
BackColor=#ccccff
BorderColor=black
ShowFooter=false
CellPadding=3
CellSpacing=0
Font-Name=Verdana
Font-Size=8pt
HeaderStyle-BackColor=#aaaadd
EnableViewState=false
/>
</Html>
</FORM>
<script runat=server>
OleDbConnection coneccion;
DataSet tabla;
OleDbDataAdapter q;
void EVENTO1(object sender, EventArgs e)
{
coneccion=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\\sites\\content\\I\\s\\c\\IscAlamilla\\d atabase\\Refaccionaria.mdb");
q=new OleDbDataAdapter("select * from Clientes", coneccion);
DataSet tabla= new DataSet();
q.Fill(tabla, "Clientes");
TABLAGRID.DataSource=tabla;
TABLAGRID.DataMember="Clientes";
TABLAGRID.DataBind();
}
void BORRAR (Object sender, EventArgs e)
{
string adap="delete from Clientes where clave=@CLAVE";
OleDbCommand orden= new OleDbCommand(adap, coneccion);
orden.Parameters.Add(new OleDbParameter("@CLAVE", OleDbType.Integer));
orden.Parameters["@CLAVE"].Value = CLAVE.Text;
orden.Connection.Open();
orden.ExecuteNonQuery();
orden.Connection.Close();
q=new OleDbDataAdapter("select * from Clientes", coneccion);
DataSet tabla= new DataSet();
q.Fill(tabla, "Clientes");
TABLAGRID.DataSource=tabla.Tables["Clientes"].DefaultView;
TABLAGRID.DataBind();
CLAVE.Text=" ";
}
</script>