5 Replies - 2435 Views - Last Post: 28 June 2011 - 12:04 PM Rate Topic: -----

#1 sharmistha_sau  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 28-June 11

can't convert db image path string as an image in datagridview col

Posted 28 June 2011 - 05:36 AM

i've entered image path from vb.net to oledb but can't convert it as an image to the datagridview column.
Is This A Good Question/Topic? 0
  • +

Replies To: can't convert db image path string as an image in datagridview col

#2 CodeCapition1  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 57
  • Joined: 23-September 10

Re: can't convert db image path string as an image in datagridview col

Posted 28 June 2011 - 06:27 AM

what exactly are you trying to do with the image? display it in the grid view or use the path stored in the grid to call a picture for something else to use?
Was This Post Helpful? 0
  • +
  • -

#3 arvindthakur  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 133
  • Joined: 07-June 11

Re: can't convert db image path string as an image in datagridview col

Posted 28 June 2011 - 06:28 AM

I think you have to provide more explaination of your error, like give your LOC where this error is occuring.
Was This Post Helpful? 0
  • +
  • -

#4 Nightfish  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 74
  • View blog
  • Posts: 158
  • Joined: 24-May 11

Re: can't convert db image path string as an image in datagridview col

Posted 28 June 2011 - 06:33 AM

How to: Display Images in Cells of the Windows Forms DataGridView Control

This probably has the answer to your question. Worksf or me, at least. First hit on google ftw ;)

This post has been edited by Nightfish: 28 June 2011 - 06:33 AM

Was This Post Helpful? 0
  • +
  • -

#5 sharmistha_sau  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 28-June 11

Re: can't convert db image path string as an image in datagridview col

Posted 28 June 2011 - 11:59 AM

Here I use image path as a string in “picture” table in “imagepath”field
I use vb.net and oledb connection. No Asp.net here.

  Private Sub btnbrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbrowse.Click
        Dim myconn As New OleDbConnection
        Dim mycommand As New OleDbCommand
        Dim mycommand1 As New OleDbCommand
        Dim mydataada As New OleDbDataAdapter()
        Dim mydataset As New DataSet()
        GetConnect()
        Try
            Me.OpenFileDialog1.Title = "Set Image File"
            Me.OpenFileDialog1.DefaultExt = "*.bmp"
            Me.OpenFileDialog1.Filter = "Bitmap Files(*.bmp)|*.bmp|Gif Files(*.gif)|*.gif|JPEG Files(*.jpg)|*.jpg|All Files(*.*)|*.*"
            Me.OpenFileDialog1.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
            If (Me.OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) And (Me.OpenFileDialog1.FileName.Length > 0) Then
                Me.PictureBox1.Image = Image.FromFile(Me.OpenFileDialog1.FileName)
                Me.txtbrowse.Text = Me.OpenFileDialog1.FileName.ToString
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

    End Sub



Now I want to convert this path as an image file by which I can see picture in datagridview.


Private Sub gridview()
        Dim myconn As New OleDbConnection
        Dim mycmd As New OleDbCommand
        Dim myadp As New OleDbDataAdapter()
        Dim myset As New DataSet()
        'Dim icon As New Icon(Me.GetType())
        Dim mynwimgfld As New DataGridViewImageColumn
        GetConnect()
Try
  mycmd = conn.CreateCommand
            mycmd.CommandText = "select * from picture"
            myadp.SelectCommand = mycmd
            myadp.Fill(myset, "picture")
            Me.DataGridView1.DataSource = myset.Tables(0).Columns(0).DefaultValue
            Me.DataGridView1.DataSource = myset.Tables("Picture").DefaultView
            'Dim inimg As Image = Image.FromFile("Picture")            MsgBox("Error:" & ex.Source & ":" & ex.Message, MsgBoxStyle.OkOnly, "Connection Error")
        End Try
        conn.Close()



it comes like this, how this path converts as image/picture ?

Attached File(s)


This post has been edited by macosxnerd101: 28 June 2011 - 12:03 PM
Reason for edit:: Please use code tags

Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10560
  • View blog
  • Posts: 39,071
  • Joined: 27-December 08

Re: can't convert db image path string as an image in datagridview col

Posted 28 June 2011 - 12:04 PM

Duplicate threads merged. Please avoid duplicate posting.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1