title: Adding image from DataGridViewImageColumn to database in windows application
body: <p>I am working on vb.net windows application..i am populating my <code>DataGridView</code> like this.i wrote code in my form <code>load</code> event like this:</p>
  
  <pre><code>Dim cd As SqlCommandBuilder = New SqlCommandBuilder(adapter)
          adapter = New SqlDataAdapter("select c.cid,c.CompanyName,d.dtId,d.dtName as Department,d.dtPhone as Phone,d.dtEmail as Email from CompanyMaster_tbl c join  DepartmentMaster_tbl d on c.Cid=d.cId order by cid", con.connect)
          dt1 = New DataTable
          bSource = New BindingSource
          adapter.Fill(dt1) 'Filling dt with the information from the DB
          bSource.DataSource = dt1
          gv.DataSource = bSource
          gv.Columns("cid").Visible = False
          gv.Columns("dtId").Visible = False
          Dim img As New DataGridViewImageColumn
          img.HeaderText = "image"
          gv.Columns.Insert(6, img)
  </code></pre>
  
  <p>then in cell content click i wrote code like this for uploading image:</p>
  
  <pre><code>If e.ColumnIndex = 6 Then
              Dim OFDLogo As New OpenFileDialog()
              OFDLogo.Filter = "JPEG(*.jpg)|*.jpg|BMP(*.bmp)|*.bmp"
              If OFDLogo.ShowDialog() = DialogResult.OK Then
                  gv.Rows(e.RowIndex).Cells(6).Value = Image.FromFile(OFDLogo.FileName)
              End If
          End If
  </code></pre>
  
  <p>in save button i am saving my department details like this:</p>
  
  <pre><code>For i As Integer = 0 To gv.RowCount - 2
      sqlInsertT2 = "Insert Into DepartmentMaster_tbl(dtname,dtphone,dtEmail,Cid) Values ('" + myTI.ToTitleCase(gv.Rows(i).Cells(3).Value) + "','" + gv.Rows(i).Cells(4).Value + "','" + gv.Rows(i).Cells(5).Value + "'," &amp; Ccid &amp; ");"
  Next
  </code></pre>
  
  <p>i have one more field in Department master table..field Name: <code>empimage</code> and datatype <code>image</code> ..i want to save corresponding image to this table.how i can save image from my data grid view image column to database.<br>
  my <code>DataGridView</code> look like this:<img src="https://i.stack.imgur.com/SLAHg.png" alt="enter image description here"></p>