Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i have one register page when i click register all details saved in the database table,
i have another page in that one uploadfile control and create users button
in that csv file contains all details what i want seperated by comma
iam upload csv files only if i upload file and when i click create users i want register all in database
Posted
Updated 12-Aug-14 2:51am
v2
Comments
Sharmanuj 12-Aug-14 8:37am    
Give some more details what you want to achieve.
Member 10954869 12-Aug-14 8:45am    
i have one register page when i click register all details saved in the database table,
i have another page in that one uploadfile control upload button,when i click upload button i want save that file in application folder delete after completion of operation and create users button
in that csv file contains all details what i want seperated by comma
iam upload csv files only if i upload file and when i click create users i want register all in database,my doubt is how can i upload file and how can i use that file
Sharmanuj 12-Aug-14 8:50am    
See the steps in the answer to achieve this.
[no name] 12-Aug-14 8:52am    
So what is the problem exactly? "I want" is not a question or a description of any kind of a problem. What have you tried and what exactly is the problem with the code that you have written?
Member 10954869 12-Aug-14 8:57am    
i used mappath with current folder but that is not working

Follow these steps to achieve the same

1. On click of upload file read the .csv file and store the data into DataTable. for example 200 columns with 100 Rows
2. On click of button "Create user" Send this datatable to the form which will display all the users list which needs to be added.
3. Insert the data into database by either normal looping on the datatable or by Bulk insert into database.
 
Share this answer
 
Comments
Member 10954869 12-Aug-14 8:53am    
i have requirement without storing into database
Sharmanuj 13-Aug-14 1:28am    
in above comment you told you want to register all details in database. What is the exact requirement buddy
there is many ways to insert file records in database
1. create file csv or text file with comma or pipe separated ,whatever you want
2.read that file by coding and read row n column wise record
3. create Datatable with column and add the file recorded value in dataTable
4. Datatable set to Dataset like

ds.add.table(datatable)


in sql server 2008

1. create one table type with no of column which u have in file

2. create one procedure with structure type parameter with read only

then write code in procedure for read record from that parameter like

create proc user_Reister(

@userlist structure readonly

)
as
...
select * from @userlist


from vb.net or c#.net

5. set Dataset to parameter value like this

cmd.parameter("@userlist ").value = ds.Table(0)



then you can read all record in procedure

i hope it will help u for bulk insert

Note use sql server 2008 and above DB
 
Share this answer
 

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