Hello I am using Vb.net i want to update Image in PicturePox1 already image save and then when i click Datagirdview want to update but there Error "Empty path name is not legal".
- Sub update()
- If con.State = ConnectionState.Open Then
- con.Close()
- End If
- con.Open()
- qry = "Update Doc Set ID=@ID,IskaGade=@IskaGade,Aqoonsi=@Aqoonsi,Gate=@Gate,MarkhatiKowaaad=@MarkhatiKowaaad,MarkhatiLabaad=@MarkhatiLabaad,MarkhatiSadaxaad=@MarkhatiSadaxaad,Faahfaahin=@Faahfaahin,UserID=@UserID where RefNo=@RefNo"
- cmd = New SqlCommand(qry, con)
- Dim i As Short
- cmd.Parameters.AddWithValue("@ID", txtid.Text)
- cmd.Parameters.Add(New SqlClient.SqlParameter("@IskaGade", SqlDbType.Image)).Value = IO.File.ReadAllBytes(a.FileName)
- cmd.Parameters.Add(New SqlClient.SqlParameter("@Aqoonsi", SqlDbType.Image)).Value = IO.File.ReadAllBytes(b.FileName)
- cmd.Parameters.Add(New SqlClient.SqlParameter("@Gate", SqlDbType.Image)).Value = IO.File.ReadAllBytes(c.FileName)
- cmd.Parameters.Add(New SqlClient.SqlParameter("@MarkhatiKowaaad", SqlDbType.Image)).Value = IO.File.ReadAllBytes(d.FileName)
- cmd.Parameters.Add(New SqlClient.SqlParameter("@MarkhatiLabaad", SqlDbType.Image)).Value = IO.File.ReadAllBytes(ex.FileName)
- cmd.Parameters.Add(New SqlClient.SqlParameter("@MarkhatiSadaxaad", SqlDbType.Image)).Value = IO.File.ReadAllBytes(fr.FileName)
- cmd.Parameters.AddWithValue("@Faahfaahin", txtremarks.Text)
- cmd.Parameters.AddWithValue("@Date", Date.Today.ToShortDateString)
- cmd.Parameters.AddWithValue("@UserID", txtUserID.Text)
- cmd.Parameters.AddWithValue("@RefNo", txtref.Text)
- cmd.ExecuteNonQuery()
- MsgBox("Record Updated Successfully")
- filldatagrid()
Image Reader in Gridview
- Sub readImageMarkhatithree(ByVal ID As String)
- Dim dr As SqlDataReader, MyTest As Boolean = False
- Dim sql As String
- If con.State = ConnectionState.Open Then
- con.Close()
- End If
- con.Open()
- sql = "Select MarkhatiSadaxaad from Doc where id ='" & txtid.Text & "'"
- cmd = New SqlCommand(sql, con)
- cmd.CommandType = CommandType.Text
- dr = cmd.ExecuteReader
- Do While (dr.Read = True)
- Dim bits As Byte()
- bits = CType(dr.Item("MarkhatiSadaxaad"), Byte())
- Dim memorybits As New MemoryStream(bits)
- Dim bitmap As New Bitmap(memorybits)
- Markhatisadaxaad.Image = bitmap
- Markhatisadaxaad.SizeMode = PictureBoxSizeMode.StretchImage
- Loop
- dr.Close()
- End Sub
James AxsomPosted Jun 16, 2018, 4:51 PM
I think Sankara is correct.
When the datagrid displays the image, its not getting a path to load the image, its getting the actual image stored in SQL Server. There is no path and no file to be opened.
So it seems to me that, a.FileName, b.FileName, c.FileName, d.FileName, ex.FileName or fr.FileName or any combination of these may be an empty string.
Sankara Krishnan VenugopalPosted May 2, 2018, 4:16 AM