473,387 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Asp.net[vb] : Reading records with null values

ak1dnar
1,584 Expert 1GB
Hi all,

I am getting this error in my ASP.net App, when reading some records which contains Null values for some of the columns.

Expand|Select|Wrap|Line Numbers
  1. System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values. at System.Data.SqlTypes.SqlString.get_Value() at System.Data.SqlClient.SqlDataReader.GetString(Int32 i) at MyAPP.step_2.GetClinics(Object ThisSelectedLocation) in D:\asp_apps\MyAPP\CRS\Dir\step_2.aspx.vb:line 217 
  2.  
So here is the sample Structure of the Sql Table:
Expand|Select|Wrap|Line Numbers
  1. ID - Name - code
  2. 2395 Some_name_goes_here NULL // Here THere is a Null Value
  3. 2396 Some_name_goes_here 56
  4. 2397 Some_name_goes_here 88
  5.  
Here is the code:

Expand|Select|Wrap|Line Numbers
  1. What sould I do to prevent this error:
  2.  
  3. [/size]Do While (Result.Read())
  4. txt_box1.Text = Result.GetString(0).ToString
  5. txt_box2.Text = Result.GetString(1).ToStrin
  6. txt_box3.Text = Result.GetString(2).ToString
  7. Loop
  8.  
How to prevent this error?
Thanks!
Jul 25 '07 #1
2 4663
prabunewindia
199 100+
hi friend,
try with one,
just put like this

txtBox.Text= Result(index).ToString()

try and reply
Prabu
Hi all,

I am getting this error in my ASP.net App, when reading some records which contains Null values for some of the columns.

Expand|Select|Wrap|Line Numbers
  1. System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values. at System.Data.SqlTypes.SqlString.get_Value() at System.Data.SqlClient.SqlDataReader.GetString(Int32 i) at MyAPP.step_2.GetClinics(Object ThisSelectedLocation) in D:\asp_apps\MyAPP\CRS\Dir\step_2.aspx.vb:line 217 
  2.  
So here is the sample Structure of the Sql Table:
Expand|Select|Wrap|Line Numbers
  1. ID - Name - code
  2. 2395 Some_name_goes_here NULL // Here THere is a Null Value
  3. 2396 Some_name_goes_here 56
  4. 2397 Some_name_goes_here 88
  5.  
Here is the code:

Expand|Select|Wrap|Line Numbers
  1. What sould I do to prevent this error:
  2.  
  3. [/size]Do While (Result.Read())
  4. txt_box1.Text = Result.GetString(0).ToString
  5. txt_box2.Text = Result.GetString(1).ToStrin
  6. txt_box3.Text = Result.GetString(2).ToString
  7. Loop
  8.  
How to prevent this error?
Thanks!
Jul 25 '07 #2
ak1dnar
1,584 Expert 1GB
hi friend,
try with one,
just put like this

txtBox.Text= Result(index).ToString()

try and reply
Prabu
wow !
Hi prabunewindia,
It works like a charm. ! Thanks for your time.
Jul 25 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Paul M. | last post by:
Hi, I am trying to populate 3 paramters in an asp .net (vb) page redirect, the first one is ok ok and gets populated by the other two get inserted into the url for the redirect as empty strings!...
2
by: John Howard | last post by:
Where can I find a good explination and example of using VB.Net/ASP.net to browse an MS Access database using ADO.Net? Thanks in advance, John
9
by: ASP .NET Newbie | last post by:
How can I run a WebBrowser control using ASP.NET/VB.NET? I know I can use the WebClient to get the page data, but I need to be able to use the WebBrowser (AxWebBrowser)? Thanks, Chad
2
by: Kivak Wolf | last post by:
Hey, I have everything working now except for this. I have some fields that I am getting data from, then I am sending them to a SQL database. Now the empty string and VB.NET null are different...
6
by: Jerome Cohen | last post by:
I need to implement a simple application that listens for web requests on a well-known URL, grab the request , which is an XML document, and send as respnse an XML document. each client sends a...
9
by: James | last post by:
So far, is basically dispise ADO.NET & VB.NET. Here's why: Too many confusing ways to do simple things. Here are two examples that maybe someone can help me with: (1) I have TextBox controls...
4
by: S. Ahmed | last post by:
Hi all: I am new to VB, especially to VB .NET. I need to create an ActiveX DLL that I can then use in another application (LabView). I know in VB 6.0, creating ActiveX DLL was easy. The...
8
by: Jimbo | last post by:
Hello I am currently designing an internal ordering system for IT equipment. I am designing it in ASP.NET (vb) using Visual Studio 2003 and using Microsoft SQL Server I have got the system...
0
by: blackburnj55 | last post by:
Hi I am inserting some records into my access database using asp.net vb script. The problem is that "Username" is set to "Not Null" in my database and so i get the following message returned. ...
1
by: Pipo Dyer | last post by:
Hello Everybody, I am Using @@IDENTITY from MS Access (YES-It is possible) using SqlDataSource -NO STORE PROC- in ASP.NET {VB CODE} to retrieve the ID of a inserted record. Please keep in mind I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.