Data is Null. This method or property cannot be called on Null values. - by James_Mex

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


0
0
Sign in
to vote
ID 339629 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 4/23/2008 11:21:23 AM
Access Restriction Public

Description

Server Error in '/soulandblues-ecom' Application.
--------------------------------------------------------------------------------

Data is Null. This method or property cannot be called on Null values. 
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.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values.

Source Error: 


Line 136:            pc.Grupo = reader.GetInt32(reader.GetOrdinal("Grupo"))
Line 137:            pc.IDArticulo = reader.GetInt32(reader.GetOrdinal("IDArticulo"))
Line 138:            pc.Ref = reader.GetString(reader.GetOrdinal("Ref"))
Line 139:            'pc.Titulo = reader.GetString(reader.GetOrdinal("Titulo"))
Line 140:            'pc.CostoE = reader.GetDecimal(reader.GetOrdinal("CostoE"))
 

Source File: C:\Documents and Settings\James Lass\Mis documentos\Visual Studio 2008\ShopSoulandblues\App_Code\BOL\ArticulosCatalogo.vb    Line: 138 

Stack Trace: 


[SqlNullValueException: Data is Null. This method or property cannot be called on Null values.]
   System.Data.SqlClient.SqlBuffer.get_String() +80
   System.Data.SqlClient.SqlDataReader.GetString(Int32 i) +52
   CatalogoArticulos.GetCatalogoSubMenus(Int32& Padre) in C:\Documents and Settings\James Lass\Mis documentos\Visual Studio 2008\ShopSoulandblues\App_Code\BOL\ArticulosCatalogo.vb:138

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle._InvokeMethodFast(Object 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) +371
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
   System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +480
   System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1960
   System.Web.UI.WebControls.BaseDataList.GetData() +57
   System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +284
   System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +56
   System.Web.UI.WebControls.BaseDataList.DataBind() +52
   System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +76
   System.Web.UI.WebControls.BaseDataList.CreateChildControls() +63
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.PreRenderRecursiveInternal() +50
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433 
Sign in to post a comment.
Posted by Microsoft on 4/24/2008 at 10:14 AM
In AOD.NET the SqlDataReader.GetString method can only be called with non-null values. Looking the docs it mentions that SqlDataReader.IsDBNull should be called prior to calling GetString if it is possible that a null value will be returned.

Alternatively the method GetSqlString will work since it returns a SqlString structure that includes a property "IsNull" that can be used to determine whether or not the string column is null valued.

Thank you for submitting your issue on Connect,
Posted by Microsoft on 4/23/2008 at 11:31 PM
Thanks for your feedback. We are escalating this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Thank you,
Visual Studio Product Team
Posted by Microsoft on 4/23/2008 at 11:31 PM
Thanks for your feedback. We are escalating this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Thank you,
Visual Studio Product Team