How to resolve the SQLDateTime Overflow error in ASP.Net data class

by Joe Payne 1. March 2009 13:06

I've been working alot with building data classes in ASP.Net.  While building some new tables, I ran into an odd problem.   This was all part of my Solunar Time Tables project at

The SQL table has 3 different datetime columns.  All are set as Nullable in SQL.  But whenever a new instance of my data class is saved, any datetime properties that were not assigned a value throw a SQL DateTime Overflow error exception.  Sure you can get around it by setting some default value, but I don't always want/need that.

Here's what I did to fix the error:

For the property data type, use Nullable(of DateTime) instead of just DateTime like this:

Private _CutoffDate As Nullable(Of DateTime)

True, False, False)> _
Public Property CutoffDate() As Nullable(Of DateTime)


Return Me._CutoffDate

End Get

Set(ByVal value As Nullable(Of DateTime))

If Me._CutoffDate <> value Then

Me._CutoffDate = value

Me.IsDirty = True

End If

End Set

End Property

Tags: , , , ,

AC7 Articles | Personal

How to FTP files in AC7 code

by Joe Payne 2. July 2008 00:45

Did you know that you can send and receive files via FTP right in your own web pages?

Did you know you can do it with 4 lines of code AND know if it worked? Aha, now I have your attention :)

AbleCommerce 7 includes a nifty little FTP component that makes uploading and downloading files via FTP a snap. This brief tutorial will explain how to do a simple FTP upload to a remote site. Remember, since .Net programming is all server-side, this is from the perspective of your web server and not your web browser. In other words, this is how you make your web server upload a file to a remote FTP site. For drop-ship distributors like me, this is invaluable when automating the distributor order process.

The Magic

Here's a code snippet that makes an FTP connection and uploads a file:

                Dim _FTPCon As New FTPConnection
                    _FTPCon.ServerAddress = ""
                    _FTPCon.ServerPort = 21
                    _FTPCon.UserName = "ftp_user"
                    _FTPCon.Password = "ftp_password"
                    _FTPCon.UploadFile(_LocalName, _RemoteName)
                    ' File uploaded successfully

                Catch ex As Exception
                    ' Upload or connect failed

                End Try

Notice how using the TRY/CATCH command allows you to catch if the upload failed. The FTP component is designed to throw an exception if either the upload or the connect command fails. Also note that you do not have to specify the FTP:// in the host URL.

More Documentation
You can find the documentation for this nifty FTP component at The links in the online documentation do not fully work because their online docs assume you've installed the component from their CD. But there's enough there to get your started - the rest can be exposed through the Visual Studio Object Browser or simply by using the Intellisense feature in VS.

Automation is one of many keys to getting those profit margins you seek. Always try to spend more time running your business and less time doing data entry. Your bank account (and your significant other) will thank you 8)

Tags: , ,

AC7 Articles

Month List