经过测试,下面的代码运行正常。
With Tables("表A")
If .Current Is Nothing Then
Return
End If
Dim dlg As New OpenFileDialog
dlg.MultiSelect = True
dlg.Filter = "图形文件|*.bmp;*.jpg;*.gif;*.png;*.tif;*.dcm"
If dlg.ShowDialog = DialogResult.OK Then
For Each fl As String In dlg.FileNames
.AddNew()
Dim dr As DataRow = .Current.DataRow
If dr.RowState = DataRowState.Added Then '如果是新增行,必须先保存才能插入文件
dr.Save()
End If
.Current.DataRow.SQLInsertFile("文件",fl) '插入文件
'Dim pic As WinForm.PictureBox = e.Form.Controls("PictureBox1")
'pic.Image = GetImage(fl)
'Dim s As String = FileSys.GetName(fl)
Dim parts() As String = s.split(".")
.Current("姓名") = parts(0)
.Current("序号") = Format(Date.Now,"yyyyMMddhhmmss") & "-" & CurrentTable.Rows.Count
Next
End If
End With