lothos12345 Posted May 19, 2005 Posted May 19, 2005 I have an Access Database with 3 fields and one of these fields contains the filenames of images. Now assume all the image filenames are going to be the same in character length. An example is below: --Fields Name Age Image --Data Joe Test 22 00010 The problem occurs in the fact that one record can contain mulitple images. An example is below: --Fields Name Age Image --Data Joe Test 22 00010000110001200013 Now assume that every new file will start with the number 0. I need to be able to move the data from Access to SQL Server and move the images to a seperate fileserver renamed using GUID removing any "-", and the correct indexing information for the newly named images must be in the SQL Server for the record they are associated with. How can I account for the possibility of mulitple images in one record. A programming example of how to accomplish this would be greatly appreciated. Just as a note the images are .tifs Quote
lothos12345 Posted May 19, 2005 Author Posted May 19, 2005 Suggestion It has been suggested to me that I parse out the string that the image filenames has been assigned to and load it into an array. I not quite sure how to accomplish this any help would be greatly appreciated. Quote
Moderators Robby Posted May 19, 2005 Moderators Posted May 19, 2005 The proper way to do this is to create a new table to hold the image names, then join this new table with the original table. this would be your structure: User_table: (Original table) ID | Name | Age 1 | Joe Jones| 22 2 | Tom Smith | 25 Images_table: (new table) User_Table_ID | Image 1 | 00010 1 | 00011 1 | 00012 2 | 00010 2 | 00018 This allows you to re-use an image for many users. Your select would look something like this... SELECT User_table.ID, User_table.Name, User_table.Age, Images_table.Image FROM Images_table INNER JOIN User_table ON Images_table.User_table_ID = User_table.ID Let's say you wanted all images for Joe Jones you would do this... SELECT Image FROM Images_table INNER JOIN User_table ON Images_table.User_table_ID = User_table.ID WHERE User_table.Name="Joe Jones" Quote Visit...Bassic Software
lothos12345 Posted May 19, 2005 Author Posted May 19, 2005 Okay I understand but how to I parse out the file names in the orginal table. For example make: Image 0010100102 into two seperate entries in the new table like so: Image 00101 00102 How would I accomplish this programmatically. Quote
Moderators Robby Posted May 19, 2005 Moderators Posted May 19, 2005 You can't really do it with any accuracy, if you had a comma or another charachter between the numbers then it would be easy using the Split method. As it is now you can look for 2 consecutive zeros but it is certainly not full-proof. Quote Visit...Bassic Software
APaule Posted May 20, 2005 Posted May 20, 2005 Assuming the length of the names is equal you could use the regular expression class to solve the problem. First of all you have to import System.Text.RegularExpressions Dim mRegEx As Regex Dim myMatches As MatchCollection Dim M As Match mRegEx = New Regex("\\w{4}") 'assuming the name's length is 4 myMatches = mRegEx.Matches([i]Imagefield[/i] ) For Each M In myMatches 'assign M.ToString to the array holding the names of the current record Next Hope this helps. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.