Error en Webpart propio

08/07/2004 - 17:30 por Leticia Martín | Informe spam
Hola, he conseguido crear diferentes web parts. Pero
cuando intento crear un webpart que accede a una base de
datos y muestro los datos en un DataGrid no llega a
importarlo (consigo cargarlo pero al arrastralo)se me va
a :

"http://asweb03:82/_layouts/3082/error.aspx?
ErrorID=SpecificWebPartError&ErrorIDArgs=WebPart1&ErrorLink
TextID=MaintenancePageLinkText&ErrorLinkDescriptionID=Maint
enancePageDescription&ErrorLinkNavigateUrl=spcontnt%2Easpx%
3FPageView%3DShared%26url%3D%252fdefault%2Easpx%253fMode%
253dEdit%2526PageView%253dShared"

y aparece lo siguiente:

Error:

El elemento Web "WebPart1" parece estar causando un
problema.

Página de mantenimiento de elementos Web: Si tiene
permiso, puede usar esta página para deshabilitar
temporalmente elementos Web o quitar la configuración
personal. Para obtener más información, póngase en
contacto con el administrador del sitio.


Solucionar problemas de Windows SharePoint Services.

Os pongo el código del Webpart:


sing System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Utilities;
using System.Web.UI.HtmlControls;using System.Data;
using System.Data.SqlClient;
namespace Ultimo
{
/// <summary>
/// Description for WebPart1.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:WebPart1 runat=server></
{0}:WebPart1>"),
XmlRoot(Namespace="Ultimo")]
public class WebPart1 :
Microsoft.SharePoint.WebPartPages.WebPart
{


DataGrid MyDataGrid = new DataGrid();

protected override void
CreateChildControls (){
SqlConnection myConnection = new
SqlConnection("server=(local)
\\NetSDK;database=pubs;Integrated Security=SSPI");
myConnection.Open();
SqlDataAdapter myCommand = new
SqlDataAdapter("select au_id from Authors where au_lname
like '%Whi%'", myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds, "Authors");





this.Controls.Add(MyDataGrid );


MyDataGrid.DataSource=ds.Tables
["Authors"].DefaultView;
MyDataGrid.DataBind();
myConnection.Close();
}
protected override void RenderWebPart
(HtmlTextWriter output)
{
EnsureChildControls();
output.RenderBeginTag
("table");

output.RenderBeginTag("tr"); //Add
a row
output.RenderBeginTag("td"); //
Add a cell

//Render DataGrid
MyDataGrid.RenderControl
(output);
output.RenderEndTag(); //End of
the cell tag
output.RenderEndTag(); //End of
the row tag

output.RenderBeginTag("tr"); //Add
a row
output.AddStyleAttribute(

HtmlTextWriterStyle.Height, "5");
output.RenderBeginTag("td"); //
Add a cell
output.RenderEndTag(); //End of
the cell tag
output.RenderEndTag(); //End of
the row tag

output.RenderBeginTag("tr"); //Add
a row
output.AddStyleAttribute(

HtmlTextWriterStyle.FontWeight,
"bold");
output.RenderBeginTag("td"); //
Add a cell
output.Write("Selected Customer
Details");
output.RenderEndTag(); //End of
the cell tag
output.RenderEndTag(); //End of
the row tag

}


}
}


Gracias.
Por favor si alguien sabe algo??
Leticia.
Pd: si este código lo meto en un aspx, funciona.

Preguntas similare

Leer las respuestas

#1 CESAR DE LA TORRE [Microsoft MVP]
08/07/2004 - 21:33 | Informe spam
Si haces un Debugging del WebPart te saldrá el error.
Para hacer un Debugging de un WebPart tienes que hacer un attach to process
desde VS.NET-->debugging-->Procesos al Worker Proces de Apication Pool de
IIS que esté utilizando tu WebSite de IIS. El proceso será uno de los
w3wp.exe que aparezcan en la lista de procesos.

Si simplemente quieres que te salga el error en IE en la ejecución del
WebPart, cambia en el Web.config de SharePoint 2003 y especifica
CustomErrors a 'off' y además la opción de 'CallStack' a 'true'. Con eso te
saldrán los errores en lugar del custom error de "Página de mantenimiento de
elementos Web".

En cuanto a qué puede ser tu error... Así sin probarlo y habiendole echado
un vistazo a tu código, podría ser un problema de seguridad. Estás
especificando un string de conexión con seguridad integrada. Asegurate de
que has habilitado impersonación en el Web.config del site de SharePoint
2003, se hace habilitando la opción 'impersonation' a 'true'. (Si no haces
esto, no intenta conectarse con el usuario que está autenticado con IE).
Otra opción para probar si es esto es que uses un string de conexión a SQL
Server con usuario y password de un usuario interno de SQL Server en lugar
de utilizar seguridad integrada.

En cualquier caso, lo mas importante es que consigas ver el error, bien
haciendo Debugging o bien con las opciones de ver los errores que te decía
arriba.

César de la Torre
[Microsoft MVP - XML WebServices]
[MCSE] [MCT]

Renacimiento
Microsoft GOLD Certified Partner
www.renacimiento.com



"Leticia Martín" wrote in message
news:290c101c46500$70a6ee10$
Hola, he conseguido crear diferentes web parts. Pero
cuando intento crear un webpart que accede a una base de
datos y muestro los datos en un DataGrid no llega a
importarlo (consigo cargarlo pero al arrastralo)se me va
a :

"http://asweb03:82/_layouts/3082/error.aspx?
ErrorID=SpecificWebPartError&ErrorIDArgs=WebPart1&ErrorLink
TextID=MaintenancePageLinkText&ErrorLinkDescriptionID=Maint
enancePageDescription&ErrorLinkNavigateUrl=spcontnt%2Easpx%
3FPageView%3DShared%26url%3D%252fdefault%2Easpx%253fMode%
253dEdit%2526PageView%253dShared"

y aparece lo siguiente:

Error:

El elemento Web "WebPart1" parece estar causando un
problema.

Página de mantenimiento de elementos Web: Si tiene
permiso, puede usar esta página para deshabilitar
temporalmente elementos Web o quitar la configuración
personal. Para obtener más información, póngase en
contacto con el administrador del sitio.


Solucionar problemas de Windows SharePoint Services.

Os pongo el código del Webpart:


sing System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Utilities;
using System.Web.UI.HtmlControls;using System.Data;
using System.Data.SqlClient;
namespace Ultimo
{
/// <summary>
/// Description for WebPart1.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:WebPart1 runat=server></
{0}:WebPart1>"),
XmlRoot(Namespace="Ultimo")]
public class WebPart1 :
Microsoft.SharePoint.WebPartPages.WebPart
{


DataGrid MyDataGrid = new DataGrid();

protected override void
CreateChildControls (){
SqlConnection myConnection = new
SqlConnection("server=(local)
\\NetSDK;database=pubs;Integrated Security=SSPI");
myConnection.Open();
SqlDataAdapter myCommand = new
SqlDataAdapter("select au_id from Authors where au_lname
like '%Whi%'", myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds, "Authors");





this.Controls.Add(MyDataGrid );


MyDataGrid.DataSource=ds.Tables
["Authors"].DefaultView;
MyDataGrid.DataBind();
myConnection.Close();
}
protected override void RenderWebPart
(HtmlTextWriter output)
{
EnsureChildControls();
output.RenderBeginTag
("table");

output.RenderBeginTag("tr"); //Add
a row
output.RenderBeginTag("td"); //
Add a cell

//Render DataGrid
MyDataGrid.RenderControl
(output);
output.RenderEndTag(); //End of
the cell tag
output.RenderEndTag(); //End of
the row tag

output.RenderBeginTag("tr"); //Add
a row
output.AddStyleAttribute(

HtmlTextWriterStyle.Height, "5");
output.RenderBeginTag("td"); //
Add a cell
output.RenderEndTag(); //End of
the cell tag
output.RenderEndTag(); //End of
the row tag

output.RenderBeginTag("tr"); //Add
a row
output.AddStyleAttribute(

HtmlTextWriterStyle.FontWeight,
"bold");
output.RenderBeginTag("td"); //
Add a cell
output.Write("Selected Customer
Details");
output.RenderEndTag(); //End of
the cell tag
output.RenderEndTag(); //End of
the row tag

}


}
}


Gracias.
Por favor si alguien sabe algo??
Leticia.
Pd: si este código lo meto en un aspx, funciona.
Respuesta Responder a este mensaje
#2 CESAR DE LA TORRE [Microsoft MVP]
08/07/2004 - 21:35 | Informe spam
Aquí te explico un poco más en detalle para que te muestre los errores en la
página dentro de IE:
Para que SharePoint 2003 te muestre los errores que te genere tu WebPart que
estás desarrollando, tienes que modificar el Web.config de SharePoint 2003.
Además de poner a 'Off' la opción de custom-error, también
tienes que habilitar que muestre los errores con la opción CallStack=true.
Busca la siguiente línea y ponlo a 'true':
De:
<SafeMode MaxControls="50" CallStack="false"/>
a
<SafeMode MaxControls="50" CallStack="true"/>

Te recomiendo que te leas el siguiente artículo, donde además de esto que te
comento, también te dice como hacer Debugging con VS.NET, como hacer trazas,
etc.
http://msdn.microsoft.com/library/d...bparts.asp

César de la Torre
[Microsoft MVP - XML WebServices]
[MCSE] [MCT]

Renacimiento
Microsoft GOLD Certified Partner
www.renacimiento.com



"Leticia Martín" wrote in message
news:290c101c46500$70a6ee10$
Hola, he conseguido crear diferentes web parts. Pero
cuando intento crear un webpart que accede a una base de
datos y muestro los datos en un DataGrid no llega a
importarlo (consigo cargarlo pero al arrastralo)se me va
a :

"http://asweb03:82/_layouts/3082/error.aspx?
ErrorID=SpecificWebPartError&ErrorIDArgs=WebPart1&ErrorLink
TextID=MaintenancePageLinkText&ErrorLinkDescriptionID=Maint
enancePageDescription&ErrorLinkNavigateUrl=spcontnt%2Easpx%
3FPageView%3DShared%26url%3D%252fdefault%2Easpx%253fMode%
253dEdit%2526PageView%253dShared"

y aparece lo siguiente:

Error:

El elemento Web "WebPart1" parece estar causando un
problema.

Página de mantenimiento de elementos Web: Si tiene
permiso, puede usar esta página para deshabilitar
temporalmente elementos Web o quitar la configuración
personal. Para obtener más información, póngase en
contacto con el administrador del sitio.


Solucionar problemas de Windows SharePoint Services.

Os pongo el código del Webpart:


sing System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Utilities;
using System.Web.UI.HtmlControls;using System.Data;
using System.Data.SqlClient;
namespace Ultimo
{
/// <summary>
/// Description for WebPart1.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:WebPart1 runat=server></
{0}:WebPart1>"),
XmlRoot(Namespace="Ultimo")]
public class WebPart1 :
Microsoft.SharePoint.WebPartPages.WebPart
{


DataGrid MyDataGrid = new DataGrid();

protected override void
CreateChildControls (){
SqlConnection myConnection = new
SqlConnection("server=(local)
\\NetSDK;database=pubs;Integrated Security=SSPI");
myConnection.Open();
SqlDataAdapter myCommand = new
SqlDataAdapter("select au_id from Authors where au_lname
like '%Whi%'", myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds, "Authors");





this.Controls.Add(MyDataGrid );


MyDataGrid.DataSource=ds.Tables
["Authors"].DefaultView;
MyDataGrid.DataBind();
myConnection.Close();
}
protected override void RenderWebPart
(HtmlTextWriter output)
{
EnsureChildControls();
output.RenderBeginTag
("table");

output.RenderBeginTag("tr"); //Add
a row
output.RenderBeginTag("td"); //
Add a cell

//Render DataGrid
MyDataGrid.RenderControl
(output);
output.RenderEndTag(); //End of
the cell tag
output.RenderEndTag(); //End of
the row tag

output.RenderBeginTag("tr"); //Add
a row
output.AddStyleAttribute(

HtmlTextWriterStyle.Height, "5");
output.RenderBeginTag("td"); //
Add a cell
output.RenderEndTag(); //End of
the cell tag
output.RenderEndTag(); //End of
the row tag

output.RenderBeginTag("tr"); //Add
a row
output.AddStyleAttribute(

HtmlTextWriterStyle.FontWeight,
"bold");
output.RenderBeginTag("td"); //
Add a cell
output.Write("Selected Customer
Details");
output.RenderEndTag(); //End of
the cell tag
output.RenderEndTag(); //End of
the row tag

}


}
}


Gracias.
Por favor si alguien sabe algo??
Leticia.
Pd: si este código lo meto en un aspx, funciona.
Respuesta Responder a este mensaje
#3 Anonimo
09/07/2004 - 11:03 | Informe spam
Hola Cesar, efectivamente parece que es un error de acceso
al servidor. Me he creado un usuario de sql para ponerlo
dentro de la cadena de conexión pero me sigue dando
error.¿?
De todas formas no entiendo cómo accede a la base de datos
de los ejmplos del quickstart (que tengo instalada), es la
misma. La misma cadena.

Se te ocurre algo.
Leticia.
Respuesta Responder a este mensaje
#4 Leticia Martín
09/07/2004 - 11:42 | Informe spam

Hola Cesar, efectivamente parece que es un error de


acceso
al servidor. Me he creado un usuario de sql para ponerlo
dentro de la cadena de conexión


(SqlConnection myConnection =new SqlConnection
("server=localhost\\NetSDk;database=pubs;UID=leticia;PWD=ma
rile");)
pero me sigue dando
error.¿?
De todas formas no entiendo cómo accede a la base de


datos
de los ejmplos del quickstart (que tengo instalada), es


la
misma. La misma cadena.

Se te ocurre algo.
Leticia.
.

Respuesta Responder a este mensaje
#5 CESAR DE LA TORRE [Microsoft MVP]
11/07/2004 - 23:43 | Informe spam
Bueno, tienes que investigar sobre ese error en concreto, que ahora mismo lo
desconozco (no nos has mandado el error y su descripción).
Pero por lo menos ahora tienes algo (un error visible) por donde 'tirar del
ovillo'. ;-)

Si nos mandas el error, supongo que te podría decir algo mas.

César de la Torre
[Microsoft MVP - XML WebServices]
[MCSE] [MCT]

Renacimiento
Microsoft GOLD Certified Partner
www.renacimiento.com


"Leticia Martín" wrote in message
news:2a45101c46599$04f1be90$



Hola Cesar, efectivamente parece que es un error de


acceso
al servidor. Me he creado un usuario de sql para ponerlo
dentro de la cadena de conexión


(SqlConnection myConnection =new SqlConnection
("server=localhost\\NetSDk;database=pubs;UID=leticia;PWD=ma
rile");)
pero me sigue dando
error.¿?
De todas formas no entiendo cómo accede a la base de


datos
de los ejmplos del quickstart (que tengo instalada), es


la
misma. La misma cadena.

Se te ocurre algo.
Leticia.
.

Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaSiguiente Respuesta Tengo una respuesta
Search Busqueda sugerida