Re: Newbie: error trying to save directory path to database
- From: "Ken Tucker [MVP]" <vb2ae@xxxxxxxxxxxxx>
- Date: Sat, 2 Dec 2006 18:25:55 -0500
Hi,
Two things. First try setting the max length for the column to 500
MonkeyMasterTableDataSet.MonkeyMain.Column("Clip_filepath").MaxLength=500
Second declare newMasterRow inside of the for each loop or you will get an error about the row already being added.
Ken
------------------------------------
"Keith R" <ASpamfilterAddress@xxxxxxxxxx> wrote in message news:uPU$AbmFHHA.5000@xxxxxxxxxxxxxxxxxxxxxxx
I'm working on an windows application (vb.net express, SQL express) where I want to store a path and filename (separately) in a database, then be able to click on a row in the DataGridView to have the app load the file. In order to populate the source table in the first place, I have a button that recursively searches directories to find files of the appropriate type, and put that data into the table. Unfortunately, it isn't quite working. Relevant pieces of code are below; the error I'm getting is:Cannot set column 'Clip_FilePath'. The value violates the MaxLength limit of this column.The actual filepath value when the error occurs (the first file it finds)= "C:\Documents and Settings\Owner\Desktop\VB test video files"
In the database explorer tab, table definition: Clip_filepath is varchar(500)
I refreshed and saved everything, and even restarted VB.net and still no love.
Here is the relevant code; any help would be greatly appreciated. I'll post separately if I can't figure it out once my table is populated, but my next step will be to figure out how to avoid adding a row (in the code below) if the local_ID is already in the database.
Thanks!
Keith
....
ApexPath = folderDialog.SelectedPath
If Len(ApexPath) > 0 Then
For Each FileFound As String In Directory.GetFiles(ApexPath, "*.avi")
'***FILEINFO CLASS***
Dim fi As FileInfo = New FileInfo(FileFound)
Dim dt_fi As Date = fi.CreationTime
Dim sz_fi As Long = fi.Length
Dim ConvertedFileDate As String
Dim ConvertedFileTime As String
newMasterRow.Clip_Text_Description = ""
newMasterRow.Clip_FilePath = Path.GetDirectoryName(FileFound)
newMasterRow.Clip_FileName = Path.GetFileName(FileFound)
newMasterRow.Clip_Length = sz_fi
'populate MonkeyMain.Local_ID
ConvertedFileDate = Convert.ToString(Format(dt_fi, "yyyyMMdd"))
ConvertedFileTime = Convert.ToString(Format(dt_fi, "HHmmss"))
newMasterRow.Local_ID = ConvertedFileDate & ConvertedFileTime & "_" & Convert.ToString(sz_fi)
'this is where I get the error
Me.MonkeyMasterTableDataSet.MonkeyMain.Rows.Add(newMasterRow)
Thanks for any assistance!
Keith
.
- Follow-Ups:
- References:
- Newbie: error trying to save directory path to database
- From: Keith R
- Newbie: error trying to save directory path to database
- Prev by Date: Re: Need some Simple Help knowing when a form is accepted???????????
- Next by Date: Re: Transparent text box.
- Previous by thread: Newbie: error trying to save directory path to database
- Next by thread: Re: Newbie: error trying to save directory path to database
- Index(es):