web 2.0

VB.NET & IsDBNull()

VB.NET & IsDBNull() - IsDBNull() : Returns a Boolean value indicating whether an expression evaluates to the System.DBNull class.

ShotDev Focus:
- VB.NET & IsDBNull()

Example

IsDBNull.aspx

<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<script runat="server">

Sub Page_Load(sender As Object, e As EventArgs)

Dim strConnString As String
Dim objConn As OledbConnection
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("shotdev/mydatabase.mdb")&";Jet OLEDB:Database Password=;"
objConn = New OleDbConnection(strConnString)
objConn.Open()

Dim dtAdapter As OleDbDataAdapter
Dim dt As New DataTable
Dim strSQL As String
strSQL = "SELECT * FROM customer WHERE CustomerID = 'C003' "
dtAdapter = New OleDbDataAdapter(strSQL, objConn)
dtAdapter.Fill(dt)

If dt.Rows.Count > 0 Then
IF NOT IsDBNull(dt.Rows(0)("Name")) Then
Me.lblText.Text = dt.Rows(0)("Name")
End IF
End IF

objConn.Close()
objConn = Nothing

End Sub

</script>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<form runat="server">
<asp:Label id="lblText" runat="server"></asp:Label>
</form>
</body>
</html>

Screenshot

VB.NET & IsDBNull()
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.