![]() |
| |||||||
| Sponsored Links |
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| ||||
| ||||
| hi guys, i'm trying to get a list of results from my stored procedure (MySQL) and i'm getting this error: Code: 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 44: myConnection.Open() Line 45: ' Using Line 46: Dim myReader As MySqlDataReader = myCommand.ExecuteReader Line 47: Try Line 48: If myReader.HasRows Then Source File: c:\inetpub\wwwroot\keithdesign2\App_Code\global\DAL\ProjectsDB.vb Line: 46 Stack Trace: [SqlNullValueException: Data is Null. This method or property cannot be called on Null values.] MySql.Data.MySqlClient.MySqlDataReader.GetFieldValue(Int32 index, Boolean checkNull) +384 MySql.Data.MySqlClient.MySqlDataReader.GetString(Int32 column) +38 MySql.Data.MySqlClient.ISSchemaProvider.GetParametersFromShowCreate(DataTable parametersTable, String[] restrictions, DataTable routines) +354 [InvalidOperationException: Unable to retrieve stored procedure metadata. Either grant SELECTprivilege to mysql.proc for this user or use "use procedure bodies=false" with your connection string.] MySql.Data.MySqlClient.ISSchemaProvider.GetParametersFromShowCreate(DataTable parametersTable, String[] restrictions, DataTable routines) +413 MySql.Data.MySqlClient.ISSchemaProvider.GetProcedureParameters(String[] restrictions, DataTable routines) +502 MySql.Data.MySqlClient.ProcedureCache.GetProcData(MySqlConnection connection, String spName) +227 MySql.Data.MySqlClient.ProcedureCache.AddNew(MySqlConnection connection, String spName) +35 MySql.Data.MySqlClient.ProcedureCache.GetProcedure(MySqlConnection conn, String spName) +102 MySql.Data.MySqlClient.StoredProcedure.GetParameters(String procName) +98 MySql.Data.MySqlClient.StoredProcedure.Resolve() +148 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +545 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader() +6 Keith.ProjectsManager.Dal.ProjectsDB.GetList() in c:\inetpub\wwwroot\keithdesign2\App_Code\global\DAL\ProjectsDB.vb:46 Keith.ProjectsManager.Bll.ProjectsManager.GetList() in c:\inetpub\wwwroot\keithdesign2\App_Code\global\BLL\ProjectsManager.vb:13 [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) +308 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.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70 System.Web.UI.WebControls.GridView.DataBind() +4 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82 System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69 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.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041 Code: Public Shared Function GetList() As ProjectsList
Dim tempList As ProjectsList = Nothing
' Using
Dim myConnection As MySqlConnection = New MySqlConnection(myConfig.myConnection)
Try
Dim myCommand As MySqlCommand = New MySqlCommand("sprocProjectsSelectList", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
myConnection.Open()
' Using
Dim myReader As MySqlDataReader = myCommand.ExecuteReader
Try
If myReader.HasRows Then
tempList = New ProjectsList
While myReader.Read
tempList.Add(FillDataRecord(myReader))
End While
End If
myReader.Close()
Finally
CType(myReader, IDisposable).Dispose()
End Try
Finally
CType(myConnection, IDisposable).Dispose()
End Try
Return tempList
End Function
Any ideas? Shem |
| Sponsored Links |
|
#2
| ||||
| ||||
| That's odd that it would be pointing the error to that line. I think your error lies within this function: Code: tempList.Add(FillDataRecord(myReader))
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.Join our Folding team: DeveloperBarn Folding |
|
#3
| ||||
| ||||
| if I run the function using a straight query and not a SP, then it runs? |
|
#4
| ||||
| ||||
| Quote:
Typically this error occurs when you're trying to assign a NULL value to a variable or object, so this is quite odd... |
|
#5
| ||||
| ||||
| The second exception in the stack track may be the root cause of your error. It appears that you have a rights problem running the stored procedure. This would explain why it works as a query and not as a stored procedure.
__________________ Wolffy ------------------------ Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary. |
|
#6
| ||||
| ||||
| |
|
#8
| ||||
| ||||
| Quote:
|
|
#9
| ||||
| ||||
| GOT IT.. had to add "use procedure bodies=false" to my connection string ![]() thanks for the help guys Shem |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Return Default Date If Null | jmurrayhead | SQL Development | 16 | June 8th, 2008 10:30 PM |
| Store Calculated Values (Updating Fields) | sbenj69 | Microsoft Access | 6 | May 26th, 2008 10:18 AM |
| Accessing a Public Property in a web service | richyrich | .Net Development | 0 | May 23rd, 2008 08:42 AM |