Vb.net 2010 如何在Vb.net中将文件夹中的图像另存为数据库中的图像(Url格式)
在我的项目中,我有PictureBox和用于在PictureBox中上载图像的浏览器按钮 那么,如何在文件夹中保存图像以及在数据库中保存图像路径呢?我不明白该怎么做 我是这样做的,如下所示:Vb.net 2010 如何在Vb.net中将文件夹中的图像另存为数据库中的图像(Url格式),vb.net-2010,Vb.net 2010,在我的项目中,我有PictureBox和用于在PictureBox中上载图像的浏览器按钮 那么,如何在文件夹中保存图像以及在数据库中保存图像路径呢?我不明白该怎么做 我是这样做的,如下所示: Private Sub BtnUpdate_Click(sender As Object, e As EventArgs) Handles Button3.Click If con.State = ConnectionState.Open Then
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