Click here to Skip to main content
12,820,585 members (29,310 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
I have an 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
digimanus 14-Nov-12 10:23am
you question yourself about what you want?

1 solution

Rate this: bad
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.
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
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: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.
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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2017
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