VB.NET把图片地址存入数据库,怎么一直出错 15
求大神改正,以下是代码PublicSubButton_SelPhoto_Click(senderAsSystem.Object,eAsSystem.EventArgs)H...
求大神改正,以下是代码
Public Sub Button_SelPhoto_Click(sender As System.Object, e As System.EventArgs) Handles Button_SelPhoto.Click
Dim pic As Image
OpenFileDialog1.ShowDialog()
pic = New Bitmap(OpenFileDialog1.FileName)
PictureBox1.Image = pic
Using DB As New BenchPracticeEntities()
Dim EI As New EmployeeInfo
Dim Picaddress = CStr(System.IO.Path.GetDirectoryName(OpenFileDialog1.FileName))
EI.Photo = Picaddress
DB.AddToEmployeeInfoes(EI)
DB.SaveChanges()
End Using
End Sub 展开
Public Sub Button_SelPhoto_Click(sender As System.Object, e As System.EventArgs) Handles Button_SelPhoto.Click
Dim pic As Image
OpenFileDialog1.ShowDialog()
pic = New Bitmap(OpenFileDialog1.FileName)
PictureBox1.Image = pic
Using DB As New BenchPracticeEntities()
Dim EI As New EmployeeInfo
Dim Picaddress = CStr(System.IO.Path.GetDirectoryName(OpenFileDialog1.FileName))
EI.Photo = Picaddress
DB.AddToEmployeeInfoes(EI)
DB.SaveChanges()
End Using
End Sub 展开
1个回答
展开全部
EI.Photo的类型是什么?你存入的仅仅是文件(照片)文件路径,不是照片内容;数据库中photo字段的类型又是什么?
追问
数据库中photo设置的是string
EI.Photo = Picaddress 就是把图片地址加入数据库中
我要存的就是图片地址
追答
程序中EmployeeInfo对象只有Photo属性赋值了,难道其他属性没有或都为默认值?你要看出错语句告诉你的错误是什么。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询