如何根据ID将XLS文件上传到SQL Server

时间:2018-09-19 05:21:58

标签: sql-server vb.net xls

我在询问如何通过上传按钮将insert文件xls转换为SQL Server

我在SQL Server中有一个现有表,该表由列

组成
  

sno(id)customernamecustomeridentitydetail

snocustomernamecustomeridentity列已被填充,剩下的细节xls需要其他人通过“选定的行。

我怎么insertxls文件SQL Server IDpublic final class ClockApp extends Application { @Override public void onCreate() { super.onCreate(); startService(new Intent(getApplicationContext(), MyService.class)); } }

我的代码

Protected Sub DataUpload_Click(sender As Object, e As EventArgs)
    Dim filepath As String = "C:\New folder\" + XXUpload.UploadedFiles.ToArray(0).FileName.ToString + ".xls"
    Dim con, con1 As New OleDbConnection
    Dim cmd, cmd1 As New OleDbCommand
    Dim dt1 As New DataTable

    con.ConnectionString = "Data Source=xx;Initial Catalog=xx;User Id=xx;Password=xx;Provider=SQLNCLI10"

    con.Open()
    cmd.Connection = con

     cmd.CommandText = "Update RequestClip Set Detail = @details Where sno IN(Select sno from RequestClip); "
    cmd.Parameters.AddWithValue("@details", filepath)

    cmd.ExecuteNonQuery()
    con.Close()

    ClipGrid.DataBind()
End Sub

预期产量

sno     customername   customeridentity       detail
  1             john                  1      123.xls  
  2              max                  2      223.xls

0 个答案:

没有答案