Click here to Skip to main content
Sign Up to vote bad
good
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 4:21am

Comments
digimanus - 14-Nov-12 10:23am
you question yourself about what you want?

1 solution

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 - 14-Nov-12 10:50am
i want code how to use delimiter and store to list and split
Christian Graus - 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 - 14-Nov-12 10:58am
anyone pls help me out by giving sample code
Christian Graus - 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 - 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 - 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 - 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 - 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
Your Filters
Interested
Ignored
     
0 Christian Graus 577
1 Ron Beyer 341
2 Tadit Dash 243
3 samadhan_kshirsagar 229
4 OriginalGriff 201
0 Sergey Alexandrovich Kryukov 7,061
1 Prasad_Kulkarni 3,815
2 OriginalGriff 3,557
3 _Amy 3,370
4 CPallini 3,034


Advertise | Privacy | Mobile
Web04 | 2.6.130619.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid