I have created a Web Service in Visual Studio 2005, using VB .NET language. This Web Service interacts with a database on Sql Server through ADO .NET.
Using ADO .NET I get one table with this code
conn = New SqlConnection(Utilities.ConnectionString)
sqlcmd = New SqlClient.SqlCommand()
sqlcmd.Connection = conn
sqlcmd.CommandType = CommandType.Text
sqlcmd.CommandText = "select * from myTable"
da = New SqlClient.SqlDataAdapter()
da.SelectCommand = sqlcmd
table = New DataTable()
da.Fill(table)
where Utilities is a class created by me for managing and return ConnectionString.
The table myTable contains more than one field of String type and just one field of datetime named LastChangeDate.
I want select all the dates found in the rows of myTable so I use this code:
Dim d As DateTime
For Each row In table.Rows
d = row.Item("LastChangeDate")
'
' other codes for managing the retuned dates
'
The problem is that after this operation d contains NULL value.
What can I do for convert correctly the datetime returned from Item method into DateTime in VB .NET
1 Answer