| | |
Exception Data is Null. This method or property cannot be called on Null values.
Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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
Views: 9461 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2005 30minutes 2005 2008 access application arithmetic array basic binary bing button buttons c# center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design designer dissertation dissertations dissertationthesis dll dropdownlist error excel file-dialog folder ftp google hardcopy highlighting image images inline installer listview login mobile ms navigate net networking opacity output peertopeervideostreaming picturebox picturebox1 plugin port print printing problem problemwithinstallation project reports" save savedialog searchbox serial server soap sorting sql string studio syntax tcp text textbox timer toolbox trim updown usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





