ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Display Image with CheckBox from Database in Windows Form DataGridView using C# and VB.Net<p>Hey <a class="username" rel="pujandoshi"> pujandoshi</a>,</p> <p>Please refer below sample.</p> <p><span style="text-decoration: underline;"><strong>Database</strong></span></p> <p>For this sample i am&nbsp;using of a table named tblFiles whose schema is defined as follows.</p> <p><img src="https://www.aspsnippets.com/Handlers/DownloadFile.ashx?File=4ebbac64-598a-4fed-9c6d-739c716bfb57.png" alt="" width="388" height="160" /></p> <p>You can download the database table SQL by clicking the download link below.</p> <p><a href="https://www.aspsnippets.com/DownloadFile.aspx?File=FilesDB.sql" target="_blank">Download SQL file</a></p> <p>For insert refer below article.</p> <h1 class="header"><a title="Save (Insert) Image in Database in Windows Application using C# and VB.Net'a" href="https://www.aspsnippets.com/Articles/Save-Insert-Image-in-Database-in-Windows-Application-using-C-and-VBNet.aspx">Save (Insert) Image in Database in Windows Application using C# and VB.Net</a></h1> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Data.SqlClient;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Data.SqlClient </pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">public Form1() { InitializeComponent(); this.GetPics(); DataGridViewCheckBoxColumn checkBoxColumn = new DataGridViewCheckBoxColumn(); checkBoxColumn.HeaderText = &#34;&#34;; checkBoxColumn.Width = 30; checkBoxColumn.Name = &#34;checkBoxColumn&#34;; dataGridView1.Columns.Insert(0, checkBoxColumn); } private void GetPics() { string constring = @&#34;Data Source=.\SQL2005;Initial Catalog=dbFiles;User id = sa;password=pass@123&#34;; using (SqlConnection con = new SqlConnection(constring)) { using (SqlCommand cmd = new SqlCommand(&#34;select TOP 4 Data, Name from tblFiles WHERE ContentType=&#39;image/jpeg&#39; ORDER BY ID ASC&#34;, con)) { DataTable dt = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.Fill(dt); dataGridView1.DataSource = dt; } } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Public Sub New() InitializeComponent() Me.GetPics() Dim checkBoxColumn As DataGridViewCheckBoxColumn = New DataGridViewCheckBoxColumn() checkBoxColumn.HeaderText = &#34;&#34; checkBoxColumn.Width = 30 checkBoxColumn.Name = &#34;checkBoxColumn&#34; dataGridView1.Columns.Insert(0, checkBoxColumn) End Sub Private Sub GetPics() Dim constring As String = &#34;Data Source=.\SQL2005;Initial Catalog=dbFiles;User id = sa;password=pass@123&#34; Using con As SqlConnection = New SqlConnection(constring) Using cmd As SqlCommand = New SqlCommand(&#34;select TOP 4 Data, Name from tblFiles WHERE ContentType=&#39;image/jpeg&#39; ORDER BY ID ASC&#34;, con) Dim dt As DataTable = New DataTable() Dim sda As SqlDataAdapter = New SqlDataAdapter(cmd) sda.Fill(dt) dataGridView1.DataSource = dt End Using End Using End Sub</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://imgur.com/0zHiSAZ.gif" alt="" width="284" height="278" /></p>https://www.aspforums.net:443/Threads/597772/Display-Image-with-CheckBox-from-Database-in-Windows-Form-DataGridView-using-C-and-VBNet/https://www.aspforums.net:443/Threads/597772/Display-Image-with-CheckBox-from-Database-in-Windows-Form-DataGridView-using-C-and-VBNet/Thu, 10 Jan 2019 02:25:32 GMT