62,046
社区成员
发帖
与我相关
我的任务
分享
Dim name As String = "size_" & DateTime.Now.ToString("ddHHmmss") + "." & hz
Dim filename As String = Server.MapPath("xls/" + name)
File1.PostedFile.SaveAs(filename)
File1.PostedFile.ContentType.ToString()
'建立EXCEL连接,读入数据
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & filename & "';Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'"
Dim da As New Data.OleDb.OleDbDataAdapter("SELECT 款号,规格,数量 FROM [Sheet1$]", strConn)
Dim ds As New Data.DataSet
ds = New Data.DataSet
da.Fill(ds)
Dim tb As New Data.DataTable
tb = ds.Tables(0)
If tb.Rows.Count > 0 Then
Dim i As Integer
For i = 0 To tb.Rows.Count - 1
Try
Dim bm_cj, size As String
Dim quantity As Integer
bm_cj = tb.Rows.Item(i).Item(0)
size = tb.Rows.Item(i).Item(1)
quantity = tb.Rows.Item(i).Item(2)
If quantity <= 0 Then
quantity = 0
End If
code.Data_updatefw("Insert Into A_Product_Size_linshi(A_bm_cj,A_Size,a_quantity) values('" & bm_cj & "','" & size & "','" & quantity & "')")‘此行是插入到数据库的代码
Catch ex As Exception
End Try
Next
File.Delete(filename)‘删除上传的文件