|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Newbie: error trying to save directory path to databasewant 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 The actual filepath value when the error occurs (the first file it finds)= > of this column. "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 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 ------------------------------------ Show quoteHide quote "Keith R" <ASpamfilterAddress@NoMail.org> wrote in message news:uPU$AbmFHHA.5000@TK2MSFTNGP03.phx.gbl... > 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 > Ken- thank you- this helped identify that whatever is going in, it is more
complicated than I thought... and additional help would be appreciated. I moved the Dim newMasterRow inside the loop as you suggested (thank you) but when I added the maxlength line, I get the error: 'column' is not a member of 'mymoviecollection1.monkeymastertabledataset.monkeymaindatatable'. I started this project with the mymoviecollection sample app, and have made major modifications- I didn't think that there were still any references to mymoviecollection at all, other than the old resource files (for button faces)...I even searched to make sure i hadn't missed any. The only tables in my project are (in MonkeyMasterTableDataSet): FlagButtonText, MonkeyFlags, and MonkeyMain (which has a linked copy of MonkeyFlags in the Data sources window, presumably due to a foreign key). Same in my Database Exlporer/Data connections- I only have my three tables, and one database diagram to show the foreign key link. Since I'm not sure where it would be getting a mymoviecollection reference, where else should I be looking (to get rid of it, as appropriate)? I'm assuming that whatever is going on must be related to my original problem adding rows. Thank you again, Keith Show quoteHide quote "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message news:B635C4A2-ED1B-4D7F-A109-B2D1824AB5FF@microsoft.com... > 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@NoMail.org> wrote in message > news:uPU$AbmFHHA.5000@TK2MSFTNGP03.phx.gbl... >> 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 >> > Nevermind, I got it :)
Still not sure why it was referencing mymoviecollection, but at least it is working now. Thanks, Keith Show quoteHide quote "Keith R" <ASpamfilterAddress@NoMail.org> wrote in message news:uNCFCzmFHHA.1232@TK2MSFTNGP05.phx.gbl... > Ken- thank you- this helped identify that whatever is going in, it is more > complicated than I thought... and additional help would be appreciated. > > I moved the Dim newMasterRow inside the loop as you suggested (thank you) > but when I added the maxlength line, I get the error: > 'column' is not a member of > 'mymoviecollection1.monkeymastertabledataset.monkeymaindatatable'. > > I started this project with the mymoviecollection sample app, and have > made major modifications- I didn't think that there were still any > references to mymoviecollection at all, other than the old resource files > (for button faces)...I even searched to make sure i hadn't missed any. The > only tables in my project are (in MonkeyMasterTableDataSet): > FlagButtonText, MonkeyFlags, and MonkeyMain (which has a linked copy of > MonkeyFlags in the Data sources window, presumably due to a foreign key). > Same in my Database Exlporer/Data connections- I only have my three > tables, and one database diagram to show the foreign key link. > > Since I'm not sure where it would be getting a mymoviecollection > reference, where else should I be looking (to get rid of it, as > appropriate)? I'm assuming that whatever is going on must be related to my > original problem adding rows. > > Thank you again, > Keith > > > "Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message > news:B635C4A2-ED1B-4D7F-A109-B2D1824AB5FF@microsoft.com... >> 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@NoMail.org> wrote in message >> news:uPU$AbmFHHA.5000@TK2MSFTNGP03.phx.gbl... >>> 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 >>> >> > >
enter key press
best way to learn Windows Forms Merging two tables in Dataset? I only want to get the matching info based on the two key fields Database Connection Designer Variables Working with a database How to set an objects property using Reflection PIAs for Excel 9.0 Make Code Fail How Do I Kill Non-Printable Characters? Select All CheckBoxes Key Validation |
|||||||||||||||||||||||