Stored Procedure - filename

fpineda101

Well-known member
Joined
Nov 14, 2005
Messages
122
Location
Los Angeles, CA
Programming Experience
1-3
I'm trying to store filenames into a database and then upload the file to the server. First step of this process is storing the filename. Below is my code. An error is thrown saying something like file is going to be truncated.

sqlINS.Parameters.Add(New SqlParameter("@ObjectiveFile", SqlDbType.NVarChar, 50))
sqlINS.Parameters(
"@ObjectiveFile").Value = fleUpload1.FileName
sqlINS.Parameters.Add(
New SqlParameter("@AudienceFile", SqlDbType.NVarChar, 50))
sqlINS.Parameters(
"@AudienceFile").Value = fleUpload2.FileName
sqlINS.Parameters.Add(
New SqlParameter("@CopyPointsFile", SqlDbType.NVarChar, 50))
sqlINS.Parameters(
"@CopyPointsFile").Value = fleUpload3.FileName
sqlINS.ExecuteNonQuery()
sconn.Close()

Try
CopyFilesToServer()
Catch ex As Exception
End Try

Private Sub CopyFilesToServer()
Dim savePath1 As String = "C:\Inetpub\FileUploads"
Dim savePath2 As String = "C:\Inetpub\FileUploads"
Dim savePath3 As String = "C:\Inetpub\FileUploads"
Dim savePath4 As String = "C:\Inetpub\FileUploads"
If (fleUpload1.HasFile) Then
Dim fileName1 As String = fleUpload1.FileName
savePath1 += fileName1
fleUpload1.SaveAs(savePath1)
End If
If (fleUpload2.HasFile) Then
Dim fileName2 As String = fleUpload2.FileName
savePath2 += fileName2
fleUpload2.SaveAs(savePath2)
End If
If (fleUpload3.HasFile) Then
Dim fileName3 As String = fleUpload3.FileName
savePath3 += fileName3
fleUpload3.SaveAs(savePath3)
End If
If (fleUpload4.HasFile) Then
Dim fileName4 As String = fleUpload4.FileName
savePath4 += fileName4
fleUpload4.SaveAs(savePath4)
End If
End Sub

Am I supposed to use another property of the fileupload? Please help!
 
Back
Top