Tutorials
Resources
Forum
Communities
Interview
Jobs
Projects
Offshore Development
Silverlight Tutorials
|
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Revenue Sharing
|
Prizes & Awards
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
Deepika Harida...
(114)
Abraham Kuriak...
(101)
shekhar
(81)
Last 7 Days
UmaShankar
(1211)
ANIL PANDEY
(659)
Deepika Harida...
(534)
more...
New Feature:
Community Sites
:
Create your own .NET community website and start earning from Google AdSense !
It's Free !
How to handle Database Nulls in a DataReader
Posted Date: 03 May 2008 Resource Type:
Articles
Category:
Databases
Posted By:
andy robarts
Member Level:
Gold
Rating:
Points
: 0
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDB" %>
<html>
<head>
<meta name="GENERATOR" Content="ASP Express 2.2">
<title>Handling Database Nulls with a DataReader</title>
<script language="VB" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
Dim strConn as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& server.mappath(".\BIBLIO.MDB") & ";"
Dim MySQL as string = "Select author, [Year Born] from Authors"
Dim MyConn as New OleDBConnection(strConn)
Dim objDR as OleDBDataReader
Dim Cmd as New OLEDBCommand(MySQL, MyConn)
MyConn.Open()
objDR=Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
MyDataList.DataSource = objDR
MyDataList.DataBind()
End Sub
Function fixBirthDate(sItem) as String
if sItem is System.DBNull.Value Then
fixBirthDate="<i><font Color='#FF0000'>No Date Specified</font></i>"
else
fixBirthDate="<b>" & sItem & "</b>"
End If
End function
</script>
</head>
<body>
<asp:DataList runat="server"
Id="MyDataList"
GridLines="Both"
cellpadding="2"
cellspacing="2"
Headerstyle-Font-Name="Arial"
Headerstyle-Font-Size="8"
Font-Name="Arial"
Font-Bold="false"
RepeatDirection="Horizontal"
RepeatColumns="4"
Font-Size="8">
<ItemTemplate>
<%# Container.DataItem("Author")%> -
<%# fixBirthDate(Container.DataItem("YearBorn"))%>
</ItemTemplate>
</ASP:DataList>
</body>
</html>
Responses
Author:
Sebastian
13 Jun 2008
Member Level:
Gold
Points
: 1
This is very informative. Thanks for sharing the details.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
(No tags found.)
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
How to handle 'DBNull' while using a DataReader
Previous Resource:
Implementing Table Inheritance in SQL Server
Return to Discussion Resource Index
Post New Resource
Category:
Databases
Post resources and
earn money
!
Related Resources
Types of Joins in Sql
How to read data from a different Server in SQL Server?
How to replace cursors with a trick:)?
Tables and objects having keywords as its name
Find all Triggers in a Database
dotNet Slackers
BizTalk Adaptors
Web Design
conference call definitions
Contact Us
Privacy Policy
Terms Of Use