我已经通过上传按钮询问如何 xls
xls
文件到 SQL Server
.
我在 SQL Server
中有一个由列组成的现有表
sno(id),customername,customeridentity,detail .
列 sno
, customername
和 customeridentity
已经填充,只需要留下需要通过所选行上传按钮上传的详细信息 xls
.
我如何 insert
SQL Server
文件 SQL Server
由 ID
?
我的代码
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