Getting "1/1/0001 12:00:00 AM" for a datetime SQL field when there are no records for that field.
Posted on 2004-04-27
Problem: "1/1/0001 12:00:00 AM" is assigned to dtInvDate
"0" to curInvAmt
When there is no record matching the query below. How can I have the two variables to display nothing in their respective textboxes when there is no record?
Dim strInvoiceNo As String
Dim curInvAmt As Double
Dim dtInvDate As DateTime
strSQL2 = "SELECT InvoiceNo, InvoiceAmount, InvoiceDate FROM tblInvoice Where ObligationID = " & request("obid")
cmdObl2 = New SqlCommand(strSQL2,dsConn2)
dtrObl2 = cmdObl2.ExecuteReader()
If dtrObl2.HasRows Then
strInvoiceNo = dtrObl2("InvoiceNo")
curInvAmt = dtrObl2("InvoiceAmount")
dtInvDate = dtrObl2("InvoiceDate")
strInvoiceNo = ""
curInvAmt = Nothing
dtInvDate = Nothing
Please help. I need a solution to this problem urgently. I have to be able to deal with NULLS in .NET. In ASP this was not a problem.