问题描述
在我的项目中,我有PictureBox和用于在PictureBox中上传图像的浏览器按钮
所以如何保存文件夹中以及如何在数据库中保存图像路径我不能理解
我正在这样做,如下所示:
Private Sub BtnUpdate_Click(sender As Object,e As EventArgs) Handles Button3.Click
If con.State = ConnectionState.Open Then
con.Close()
End If
con.open()
cmd = con.CreateCommand()
cmd.CommandType = CommandType.Text
Dim fname As String
Dim folder As String = "F:\Project In Asp.Net\VB.NET\Login\Login\Files"
Dim pathString As String = System.IO.Path.Combine(folder,fname)
Dim Id = Convert.ToString(combovehiclesmodel.SelectedValue)
cmd.CommandText = "update Services set Servicesname = '" & txtservicesname.Text & "',Servicestypes='" & txtservicestype.Text & "',Fees='" & txtservicesfees.Text & "',damages='" & txtdamage.Text & "',Replace='" & txtreplace.Text & "',VehiclesId='" & Id & "',ServicesImage = @pathString = '" & PictureBox1.Text & "',where ServicesId=" & i & ""
cmd.Parameters.AddWithValue("@pathString",pathString)
cmd.ExecuteNonQuery()
Dim a As Image = PictureBox1.Image
a.Save(pathString)
NotifyIcon1.ShowBalloonTip(1000,"Update","Update SuccessFull !!",ToolTipIcon.Info)
disp_data()
txtservicesname.Text = ""
txtservicestype.Text = ""
txtservicesfees.Text = ""
txtdamage.Text = ""
txtreplace.Text = ""
combovehiclesmodel.Text = ""
End Sub
还有我的浏览器按钮,它单击了事件
Private Sub Btnbrowser_Click(sender As Object,e As EventArgs) Handles Btnbrowser.Click
Dim op As OpenFileDialog = New OpenFileDialog
op.Filter = "Image File (*.jpg;*.bmp;*.gif)|*.jpg;*.bmp;*.gif"
If op.ShowDialog = DialogResult.OK Then
PictureBox1.Image = Image.FromFile(op.FileName)
End If
End Sub
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)