将多行传递给SQL Server存储过程

时间:2015-06-05 07:35:30

标签: excel sql-server-2008 stored-procedures import c#-2.0

我有一个问题,我想将多行Excel文件传递给SQL Server notificationItem( text = tags$div(textOutput("regis"),style = "display: inline-block; vertical-align: middle;"), icon("users") ),我对此一无所知。 我有一个要导入的Excel文件,需要将数据插入三个不同的表中。我已成功将数据导入到一个表中,如下所示

stored procedure

如何将行发送到存储过程而不是任何string path = string.Concat((Server.MapPath("~/temp/"+FileUpload1.FileName))); FileUpload1.PostedFile.SaveAs(path); OleDbConnection oleCon = new OleDbConnection("Provider=Microsoft.Ace.OLEDB.12.0;Data Source=" + path + ";Extended Properties = Excel 12.0;"); OleDbCommand cmd = new OleDbCommand("select * from [Sheet1$]",oleCon); OleDbDataAdapter dtap = new OleDbDataAdapter(cmd); oleCon.Open(); DbDataReader rdr = cmd.ExecuteReader(); string con_str = @"Data source = .;Initial Catalog=practiceDB;Integrated security=True"; SqlBulkCopy bulkInsert = new SqlBulkCopy(con_str); bulkInsert.DestinationTableName = "Excel_New"; bulkInsert.WriteToServer(rdr); oleCon.Close(); Array.ForEach(Directory.GetFiles((Server.MapPath("~/temp/"))),File.Delete);

1 个答案:

答案 0 :(得分:0)

不是将行作为参数传递,而是只从存储过程中的表Excel_New中读取它?