sql更新用这种方式:
Dim dr As DataRow = Tables("职员信息管理_职员信息表").Current.DataRow
If dr IsNot Nothing
Dim dlg As New OpenFileDialog
dlg.Filter = "图形文件|*.bmp;*.jpg;*.gif;*.png"
If dlg.ShowDialog = DialogResult.OK Then
dr.SQLInsertFile("photo",dlg.FileName) '插入文件
Dim pic As WinForm.PictureBox = e.Form.Controls("PictureBox1")
Dim imgStream As New IO.MemoryStream
Dim b As New Bitmap(pic.Image)
b.Save(imgStream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim data As Byte() = imgStream.GetBuffer
imgStream.Dispose()
Dim conn As New System.Data.SqlClient.SqlConnection("server=localhost;database=test;Integrated Security=true;") '改为自己的连接字符串
conn.Open()
Dim sqlcomm As New System.Data.SqlClient.SqlCommand
sqlcomm.Connection = conn
sqlcomm.CommandText = "UPDATE [职员信息表] SET [photo] = @photo WHERE [sysid] = @sysid "
sqlcomm.Parameters.Add("@photo", System.Data.SqlDbType.Image).Value = data
sqlcomm.Parameters.Add("@sysid", System.Data.SqlDbType.NVarChar).Value = dr("SysId")
sqlcomm.ExecuteNonQuery()
conn.Close()
End If
End If
不然就加载表进来用吧