In this post we fully learn how we can add SQL Server data to Datagridview. This is very easy task. For this we have to take only Datagridview from toolbox. After that the coding has to be used as per the instruction of the video. We may need this work at this time. When we need to show any data from SQL to our software.
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.IO
Public Class Form1
Sub fillRec(ByVal sender As String)
cmmd.Connection = ccnn
cmmd.CommandText = "SELECT * FROM Table1"
Dim daa = New SqlDataAdapter(cmmd)
Dim dtt As New DataTable
daa.Fill(dtt)
DataGridView1.DataSource = dtt
End Sub
Dim cconnString1 As String = ""
Dim ccnn As New SqlConnection(cconnString1)
Dim cmmd As New SqlCommand
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
fillRec("")
End Sub
End Class
How Hide DataGridView Column in vb.net
Me.DataGridView1.Columns("ID").Visible = False