Foros del Web » Programando para Internet » ASPX (.net) »

Por qué me da este error?

Estas en el tema de Por qué me da este error? en el foro de ASPX (.net) en Foros del Web. Tengo un gridview y como datasource tiene un objectdatasource, hasta ahí todo bien. El problema es que cuando le doy "play" para ver como va ...
  #1 (permalink)  
Antiguo 02/07/2006, 08:50
Avatar de Frehley  
Fecha de Ingreso: junio-2005
Ubicación: Somewhere between Heaven and Hell
Mensajes: 415
Antigüedad: 18 años, 10 meses
Puntos: 0
Mensaje Por qué me da este error?

Tengo un gridview y como datasource tiene un objectdatasource, hasta ahí todo bien. El problema es que cuando le doy "play" para ver como va quedando me tira el siguiente error:

Server Error in '/Webconmysql' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Cita:
Line 849: public override MembershipUser GetUser(object providerUserKey, bool userIsOnline)
Line 850: {
Line 851: MySqlConnection conn = new MySqlConnection(connectionString);
Line 852: MySqlCommand cmd = new MySqlCommand("SELECT PKID, Username, Email, PasswordQuestion," +
Line 853: " Comment, IsApproved, IsLockedOut, CreationDate, LastLoginDate," +

Source File: c:\Documents and Settings\Frehley\Escritorio\Webconmysql\App_Code\M ySQLMembershipProvider.cs Line: 851

Stack Trace:

Cita:
[NullReferenceException: Object reference not set to an instance of an object.]
MySql.Data.Common.DBConnectionString.ParseKeyValue Pairs(String src) +42
MySql.Data.Common.DBConnectionString.Parse(String newConnectString) +31
MySql.Data.MySqlClient.MySqlConnection.set_Connect ionString(String value) +25
MySql.Data.MySqlClient.MySqlConnection..ctor(Strin g connectionString) +70
Andri.Web.MySqlMembershipProvider.GetUser(Object providerUserKey, Boolean userIsOnline) in c:\Documents and Settings\Frehley\Escritorio\Webconmysql\App_Code\M ySQLMembershipProvider.cs:851

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle._InvokeMethodFast(Objec t target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +72
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +358
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
System.Web.UI.WebControls.ObjectDataSourceView.Inv okeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +484
System.Web.UI.WebControls.ObjectDataSourceView.Exe cuteSelect(DataSourceSelectArguments arguments) +1868
System.Web.UI.DataSourceView.Select(DataSourceSele ctArguments arguments, DataSourceViewSelectCallback callback) +13
System.Web.UI.WebControls.DataBoundControl.Perform Select() +140
System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind() +68
System.Web.UI.WebControls.DetailsView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.Ens ureDataBound() +61
System.Web.UI.WebControls.DetailsView.EnsureDataBo und() +154
System.Web.UI.WebControls.CompositeDataBoundContro l.CreateChildControls() +67
System.Web.UI.Control.EnsureChildControls() +97
System.Web.UI.Control.PreRenderRecursiveInternal() +50
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5731
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42



Si en lugar de poner
Cita:
Line 851: MySqlConnection conn = new MySqlConnection(connectionString);
Pusiera la cadena de conección (data source, user, password...etc), no me tira ese error.

Espero que alguien me pueda dar una mano.

Salu2!
__________________
diegoz.com.ar
  #2 (permalink)  
Antiguo 03/07/2006, 10:03
Avatar de Alex Reyes  
Fecha de Ingreso: diciembre-2005
Ubicación: Camarillo, CA
Mensajes: 242
Antigüedad: 18 años, 4 meses
Puntos: 2
Ese es el problema, le estas pasando una variable llamada connectionString que no esta declarada. Si es un atributo de tu clase, asegurate que haya sido creada e inicializada antes de que la uses.
__________________
Alex Reyes
http://jalexreyes.spaces.live.com
  #3 (permalink)  
Antiguo 03/07/2006, 11:57
 
Fecha de Ingreso: noviembre-2005
Mensajes: 129
Antigüedad: 18 años, 5 meses
Puntos: 0
sip, la variable connectionString no está inicializada
  #4 (permalink)  
Antiguo 03/07/2006, 14:10
Avatar de Frehley  
Fecha de Ingreso: junio-2005
Ubicación: Somewhere between Heaven and Hell
Mensajes: 415
Antigüedad: 18 años, 10 meses
Puntos: 0
Muchas gracias por las respuestas.
Declaré la variable, pero la idea era declarar una única vez en todo el proyecto la cadena de conección, ahora la tengo dos vecez.
Funciona, por ahora no tengo apuro en solucionarlo.

Muchas gracias!
__________________
diegoz.com.ar
  #5 (permalink)  
Antiguo 03/07/2006, 14:22
 
Fecha de Ingreso: mayo-2004
Ubicación: Guadalajara, Jalisco, México
Mensajes: 724
Antigüedad: 20 años
Puntos: 6
Frehley, la puedes poner en el web.Config, abajo del system.web

</system.web>
<appSettings>

<add key="MiConexion" value="data source=tuServer;user id=sa;password=tuPassword; initial catalog=TuBD" />

</appSettings>

En donde vayas a hacer un acceso a tu BD solo importas el namespace...
Imports System.Configuration.ConfigurationSettings

Y usas el
AppSettings("MiConexion")
y te regresa la conexion de cadena...
  #6 (permalink)  
Antiguo 04/07/2006, 09:36
Avatar de Frehley  
Fecha de Ingreso: junio-2005
Ubicación: Somewhere between Heaven and Hell
Mensajes: 415
Antigüedad: 18 años, 10 meses
Puntos: 0
Muchisimas gracias a todos!
__________________
diegoz.com.ar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:03.