| | |
Exception Data is Null. This method or property cannot be called on Null values.
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
Exception Data is Null. This method or property cannot be called on Null values.
0
#1 Feb 11th, 2006
Hi,
in the .NET 1.1 and VB application, I am calling a store procedure [SQL-SERVER 2000] in a subroutine. the store procedure simply SELECTs rows from tables and returns data, when I try to use the data to fill the web form, it works fine until it hits any column with NULL value. When NULL column it throws an exception and does not fill rest of the columns. in the debug window I get the following error
"Data is Null. This method or property cannot be called on Null values"
I have tried "IsDBNull", IsNull, "= Nothing" all ways to catch this condition. All I want it to simply accept the null values and move ahead.
Now I can think of changing the null in store procedure into some strings just as a work around.
But want to know what is a proper way to handle this situation in VB.
thanks.
Tejoo.
in the .NET 1.1 and VB application, I am calling a store procedure [SQL-SERVER 2000] in a subroutine. the store procedure simply SELECTs rows from tables and returns data, when I try to use the data to fill the web form, it works fine until it hits any column with NULL value. When NULL column it throws an exception and does not fill rest of the columns. in the debug window I get the following error
"Data is Null. This method or property cannot be called on Null values"
VB.NET Syntax (Toggle Plain Text)
Public Sub ReadMyData() Dim MySelectQuery As String Dim MyConn As SqlConnection Dim Mycmd As SqlCommand Dim MyReader As SqlDataReader Dim objParam1 As SqlParameter Try MyConn = New SqlConnection(ConfigurationSettings.AppSettings("Conn")) If MyConn.State = ConnectionState.Closed Then MyConn.Open() End If Mycmd = New SqlCommand("sp_SelectReleaseDetails", MyConn) Mycmd.CommandType = CommandType.StoredProcedure objParam1 = Mycmd.Parameters.Add("@PX_Release_Id", SqlDbType.Int) objParam1.Value = PX_REL_ID.Text.Trim MyReader = Mycmd.ExecuteReader() MyReader.Read() Release_Label.Text = MyReader.GetString(0) ' LabelID, Release_Artist.Text = MyReader.GetString(1) 'ReleaseArtist, .. .. ... MyReader.Close() Mycmd.Dispose() MyConn.Dispose() MyConn.Close() Catch ex As Exception System.Diagnostics.Trace.WriteLine("[ReadMyData] Exception " & ex.Message) Catch exp As SqlException DisplaySqlErrors(exp) Finally MyConn.Close() End Try End Sub
I have tried "IsDBNull", IsNull, "= Nothing" all ways to catch this condition. All I want it to simply accept the null values and move ahead.
Now I can think of changing the null in store procedure into some strings just as a work around.
But want to know what is a proper way to handle this situation in VB.
thanks.
Tejoo.
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- data adapter update method won't work (VB.NET)
- Send data on a serial port (C++)
- Error: uncaught exception: Permission denied to call method XMLHttpRequest.open (HTML and CSS)
- Java Null Pointer Exception (Java)
- Logical operations and data-checks (Java)
- nullpointer exception...HELP!!! (Java)
- help with polymorphism and inheritance...getting null values (Java)
Other Threads in the VB.NET Forum
- Previous Thread: Quick VB2005 help....how do I get this basic app started?
- Next Thread: Problem with VB.NET and MS Access
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add application arithmetic array assignment basic binary bing box button buttons click code combobox component connectionstring convert cpu data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists file-dialog firewall folder google hardcopy image images isnumericfuntioncall login math memory mobile module ms msaccess mssqlbackend mysql navigate net networking opacity output peertopeervideostreaming picturebox1 port print printpreview problemwithinstallation project record regex reports" reuse right-to-left save savedialog serial sqldatbase storedprocedure string temp text textbox timer toolbox updown useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf xml





