title: Saving document file in SQL Server database using vb.net
body: <p>Please I need your help. I am trying to save a file in a SQL Server database, but it is showing this error </p>
  
  <blockquote>
    <p>Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.</p>
  </blockquote>
  
  <p>Here is my code </p>
  
  <pre><code>  Private Sub Button70_Click(sender As Object, e As EventArgs) Handles Button70.Click
      fna = content.Text
      fna.Split("\")
      ffn = fna.Last.ToString
  
      conn.Open()
      Dim com As New SqlCommand
      com.Connection = conn
      com.CommandText = "insert into meeting (Date_Entry, Title, Chairperson, Venue, File_Name, [Content]) values( '" &amp; date5.Text &amp; "', '" &amp; title.Text &amp; "', '" &amp; cp.Text &amp; "', '" &amp; vn.Text &amp; "', '" &amp; f_name.Text &amp; "', '@[Content]')"
      With com.Parameters
  
          .AddWithValue("Content", SqlDbType.VarBinary).Value = File.ReadAllBytes(content.Text)
      End With
      com.ExecuteNonQuery()
      conn.Close()
      MsgBox("File saved")
      content.Clear()
  
  
  End Sub
  
  Private Sub Button25_Click(sender As Object, e As EventArgs) Handles Button25.Click
      '// open dilogue to add file to save
      If op.ShowDialog = Windows.Forms.DialogResult.OK Then
          content.Text = op.FileName
  
      End If
  End Sub
  </code></pre>