Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I have an asp.net FileUpload control.
 
Now i want to upload multiple attachments and save uploaded file paths in sql database.
 
here how to save multiple file paths in sql server column if user uploads multiple attachments using file upload control?
 
i want the code how to save multiple file paths in sql server file path column?
Posted 14-Nov-12 5:21am
Comments
digimanus at 14-Nov-12 10:23am
   
you question yourself about what you want?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Well, you have two options. One : choose a character that is not valid for a file path, like ?, and use that as a delimiter to store a list that needs to be split. Second, create a mapping table so you can map multiple file paths to one entry by it's id. So your main table has an id column and your new table contains that id, and a file path, with one entry per path.
  Permalink  
Comments
deepisingh at 14-Nov-12 10:50am
   
i want code how to use delimiter and store to list and split
Christian Graus at 14-Nov-12 10:54am
   
This is beyond trivial. The string class has a split method, and you should use StringBuilder, not just +, to build the string. This is the least good option, overall.
deepisingh at 14-Nov-12 10:58am
   
anyone pls help me out by giving sample code
Christian Graus at 14-Nov-12 11:03am
   
string [] paths = thepath.Split('?');
 
I do recommend if you ever want to be a programmer, being willing to do basic research on your own and to know some basic concepts.
deepisingh at 14-Nov-12 11:04am
   
if user delete the file attachment then tht file path must be remove from list and save in database
Christian Graus at 14-Nov-12 11:06am
   
Sounds like a reasonable requirement. Do you intend to do any of your job yourself ? Do you expect I can give you copy/paste code to do this for you ? I can't, I don't know the DB schema for a start, and at some point, you need to be able to write code without asking others to do it for you.
deepisingh at 14-Nov-12 11:05am
   
string [] paths = thepath.Split('?');
after tht u want me to keep loop of strig builder and in every loop u want me to insert in db?
Christian Graus at 14-Nov-12 11:15am
   
I think this is the worse option. How you do it is up to you. I would recommend the other option I gave, if you were asking

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 410
1 Jochen Arndt 200
2 Richard MacCutchan 135
3 DamithSL 105
4 PIEBALDconsult 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100