Background- Front end Visual Studio 2013 using visual basic, back end MS SQL Server 2012 and I am new to visual basic.
I am using a data grid view. The code is below. The line of code
generates the following error message: "Object reference not set to an instance of an object." What am I doing wrong?
I am using a data grid view. The code is below. The line of code
Code:
DGV_CurrentRatings.Columns.Item("ID_Evaluations").Width = 0
Code:
Dim strSQL As String
strSQL = "Select * FROM Evaluations WHERE FY='" & my_CurrentFY & "' AND MD_Delete='0' AND ID_Supplier=" & my_IDSupplier & " Order By FY DESC, QTR"
Try
Dim connectionString As String = SQL_ConnectionStr2
Dim connection As New SqlConnection(connectionString)
Dim dataadapter As New SqlDataAdapter(strSQL, connection)
Dim ds As New DataSet()
connection.Open()
dataadapter.Fill(ds, "Authors_table")
connection.Close()
DGV_CurrentRatings.DataSource = ds
DGV_CurrentRatings.DataMember = "Authors_table"
DGV_CurrentRatings.Columns.Item("ID_Evaluations").Width = 0
DGV_CurrentRatings.Columns.Item("ID_Supplier").Width = 0
DGV_CurrentRatings.Columns.Item("FYStatus").Width = 0
DGV_CurrentRatings.Columns.Item("StatusDateTime").Width = 0
DGV_CurrentRatings.Columns.Item("EvalStatus").Width = 0
DGV_CurrentRatings.Columns.Item("EvalStatusDate").Width = 0
DGV_CurrentRatings.Columns.Item("FY").Width = 40
With DGV_CurrentRatings.ColumnHeadersDefaultCellStyle
.Font = New Font(DGV_CurrentRatings.Font, FontStyle.Bold)
End With
Catch EX As Exception
MsgBox(EX.Message)
Return False
Exit Function
End Try
Comment