Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have 5 FileUpload controls on a webform.. I have two sql server tables...

C#
Tbl_ClaimDetails
SrNo | Remark | BrMkrdt


Tbl_ClaimImages
SrNo | Img | Id | ImgName



The first file upload control is compulsory. For instance if a user selects 3 files to be uploaded then the first image file is used to insert data into Tbl_ClaimDetails through stored procedure (SrNo in Tbl_ClaimDetails is identity) i am returning the last srno using SCOPE_IDENTITY(). I am storing this
SQL
SCOPE_IDENTITY()
value in a variable lastid

Now i am using another stored procedure to insert data in Tbl_ClaimImages of this first image
C#

along with lastid..
C#
if (file1.ContentLength > 0 && (u1 != null || u1 != 0))
{
                Stream fs = file1.InputStream;
                BinaryReader br = new BinaryReader(fs);
                Byte[] bytes = br.ReadBytes((Int32)fs.Length);

//store procedure inserts data in tbl_claimdetails and return SCOPE_IDENTITY()
                lastid = dbo.ExecProc1(claim.Remark,  claim.BrMkrdt);
//another stored procedure inserts data in tbl_ClaimImages
                dbo.insert(bytes, lastid, file1.FileName);    
             count++;
}

if (file2.ContentLength > 0 && (u1 != null || u1 != 0))
{
                Stream fs = file2.InputStream;
                BinaryReader br = new BinaryReader(fs);
                Byte[] bytes = br.ReadBytes((Int32)fs.Length);                
                dbo.insert(bytes, lastid, file1.FileName);    
             count++;
}// and so on till file5




This approach is working fine. I do not have any errors or problem BUT i want to know if there is a better approach than this? As you can see i am executing two different stored procedures for inserting values in the given to tables. The stored procedure which inserts values in Tbl_ClaimDetails gets executed just once at the beginning and then i am executing another stored procedure again and again to insert values in Tbl_ClaimImages depending on number of images user is uploading. Is it possible all this can be done using one single stored procedure in one single execution? Or is there better approach?
Posted
Updated 29-Aug-13 19:58pm
v2

1 solution

http://www.aspdotnet-suresh.com/2012/12/jquery-uploading-multiple-files-in.html
http://www.aspdotnet-suresh.com/2012/12/jquery-uploading-multiple-files-in.html
refer this links it would be helpful
 
Share this answer
 
v2
Comments
arbaaz jalil 30-Aug-13 2:53am    
Have you even read my question?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900