.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

Insert excel field into table using stored procedure

Posted By: Catherine     Posted Date: June 08, 2011    Points:5   Category :Sql Server
Hi I have uploaded my Excel data into server. I have to insert The excel data with specified field into my database table which is already in use. I would like to do this by using stored procedure. how to write procedure to this. For example my excel field have name,id but my table tblemployee has name,id,address,acc_no. I have to insert name,id to tblemployee. please tell

Responses
Author: Gowthammanju             
Posted Date: June 08, 2011     Points: 20   

Try the following project which might help u

this consist of

1)Excel Spreadsheet File Upload.
2)Retrieving and Viewing the Excel Spreadsheet Data.
3)Importing the Excel Spreadsheet Data into a Database Table.

Download Attachment

Thanks & Regards,
GowthamManju
Chennai



Mark if the answer is true
Author: Sasi Prabhu             
Posted Date: June 08, 2011     Points: 20   

Just Create Procedure and Pass the Parameters.

To Create Procedure :

create proc Proc_ExcelValInsert
@name varchar(50),@ids int,@address varchar(300),@accno int
as
begin
insert into tblemployee vaules(@name,@ids,@address,@accno)
end

In ClassFile.cs

Public string execproc(string name,int sid,string address,int accno)
{
string result;
try
{
cmd=new sqlcommand("Proc_ExcelValInsert",con);
cmd.Commandtype=commandtype.storedprocedure;
cmd.parameters.add("@name",sqldbtype.varchar).value=name;
cmd.parameters.add("@id",sqldbtype.int).value=sid;
cmd.parameters.add("@address",sqldbtype.varchar).value=address;
cmd.parameters.add("@accno",sqldbtype.int).value=accno
cmd.executenonquery();
result="Inserted Successfully";
}
catch(exception ex)
{
result=ex.message;
}
finally{con.close();}
return result;
}


In aspx.cs Page :

ClassFile cssc=new classfile()
//Pass the Excel Datas Here
lbl_result.text=cssc.execproc(<name>,<id>,null,null);



Thanks & Regards,
Sasi Prabhu.
Author: Gowthammanju             
Posted Date: June 08, 2011     Points: 20   

Try the following project which might help u

this consist of

1)Excel Spreadsheet File Upload.
2)Retrieving and Viewing the Excel Spreadsheet Data.
3)Importing the Excel Spreadsheet Data into a Database Table.

Download Attachment

Thanks & Regards,
GowthamManju
Chennai



Mark if the answer is true
Author: Gowthammanju             
Posted Date: June 08, 2011     Points: 20   

hi

u can implement using following code

INSERT Personal (Name, ID) SELECT Name, ID 
FROM OPENROWSET('MSDASQL',
'Driver={Microsoft Excel-Treiber (*.xls)};
DBQ=<filename>;HDR=NO',
'SELECT * FROM [Tabelle1$]')

Exchange <filename> with the filename
if the excel-sheet contains header lines set HDR=YES,
[Tabelle1$] is the name of the excel-sheet.



Thanks & Regards,
GowthamManju
Chennai



Mark if the answer is true
Author: Gowthammanju             
Posted Date: June 08, 2011     Points: 20   

U can also refer the following links

for exporting access tables to access

http://databases.about.com/cs/tutorials/a/aa033003a.htm

Thanks & Regards,
GowthamManju
Chennai



Mark if the answer is true


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend