This project has moved and is read-only. For the latest updates, please go here.

web.config custom sql columns

Sep 30, 2011 at 6:46 PM


I have just implemented NeatUpload into my site and everything is working great. However, I am uploading the files to a SQL Server 2008 database and I have some custom column names in my uploads table and I can't figure out how to write that data at the same time that I upload the file.

Here is the code from my web.config file:

        <section name="neatUpload" type="Brettle.Web.NeatUpload.ConfigSectionHandler, Brettle.Web.NeatUpload" allowLocation="true" />
    <neatUpload defaultStorageProvider="SqlServerUploadStorageProvider">
            <add name="SqlServerUploadStorageProvider"
                 type="Hitone.Web.SqlServerUploader.SqlServerUploadStorageProvider, Hitone.Web.SqlServerUploader"
                 connectionName="ApplicationServices" tableName="Attachments" dataColumnName="Attachment" mimeTypeColumnName="MIMEType" 
                 fileNameColumnName="AttachmentName" datetimeColumnName="DateUploaded" useridColumnName="UserID" messageidColumnName="MessageID" />

As you can see, I would like to also write to my database values for a "DateUploaded" column, "UserID" column, and "MessageID" column.

Here is the code from my upload page:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        'filepath for images
        Dim filePath As String = "App_Data/NeatUpload_Temp/"
        Dim strFileName As String
        Dim strMIMEType As String

        Dim strFinalFile As String

        'see if there is an uploaded file
        If (InputFile1.HasFile) Then

            'get the file name
            strFileName = InputFile1.FileName
            strFinalFile = Mid(strFileName, InStrRev(strFileName, "\") + 1)

            'get the MIME type
            strMIMEType = InputFile1.ContentType

            'check the file type of uploaded file - using the MIME type
            'If strMIMEType = "image/jpeg" Or strMIMEType = "image/jpg" Or strMIMEType = "image/gif" Or strMIMEType = "image/pjpeg" Or strMIMEType = "application/docx" Then

            'carry on and upload...

            'now save the new image
            'InputFile1.MoveTo(Path.Combine(MapPath(filePath), strFinalFile), MoveToOptions.Overwrite)
            InputFile1.MoveTo((strFinalFile), MoveToOptions.Overwrite)


            'Label1.Text = "This is not a valid image file.  It must be a .jpg or .gif file type."

            'End If

        End If
    End Sub