Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Dear,
According to following code program does not show 'dat'.
How to solve it.
Please help me soon.

Actually I cant assign 'dr.Item("End_Date").ToShortDateString()' into 'dat' as a date type.

Code As:


VB.NET
Dim dat As Date
cmd.Connection = conn
cmd.CommandText = "select End_Date from employee whereID='01'"
cmd.CommandType = CommandType.Text
Dim dr As OracleDataReader = cmd.ExecuteReader()
dat = dr.Item("End_Date").ToShortDateString()
If dr.Read() Then
    MessageBox.Show("Date is: " & dat)
End If
Posted
Updated 18-May-10 3:09am
v4

Try This

VB
Try
            Dim dat As Date
            Dim conn As New OracleConnection
            Dim cmd As New OracleCommand
            cmd.Connection = conn
            cmd.CommandText = "select End_Date from employee whereID='01'"
            cmd.CommandType = CommandType.Text
            conn.Open()
            Dim dr As OracleDataReader = cmd.ExecuteReader()
            While dr.Read
                dat = dr.GetDateTime(0)
                MsgBox("Date is : " & dat.ToShortDateString)
            End While
            dr.Close()
        Catch ex As OracleException
            MsgBox("Database Error")
        Finally
            If conn.State = ConnectionState.Open then
               conn.Close
            End If
        End Try



Happy Coding
 
Share this answer
 
v2
use

MessageBox.Show("Date is:" & dat.ToString());

or give some more details regarding your code. eg. what it is showing (null, empty string etc.)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900