An object-oriented programming language developed by Microsoft that can be used in .NET.
Hi
You do have 'ponumbner', but no 'ponumber' in your code (line 19). One or the other needs to be changed.
You have assigned the datatable 'dt' as the datasource for the datagridview (at line 111), which is the reason you are getting the exception as you can not add a row to a bound DataGridView. As Viorel is pointing out, you can add rows to the DataTable, and the new row will 'automatically' appear in the DataGridView (courtesy of the binding).
A point to consider: if you check out the With xxxx End With structure, you would see that you could save yourself a LOT of typing (or copy/pasting). For example, With DataGridview1..... End With as below.
(NOTE ALSO A COUPLE ERRORS USING A STRING AS AN INTEGER VALUE.)
Option Strict On
Option Explicit On
Public Class Form1
Dim dt As New DataTable("Freddy")
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With DataGridView1
' SEE SPELLING FOR COLUMN NAME
.Columns(0).Name = "ponumbner"
.Columns(0).HeaderText = "PO Number"
.Columns(0).DataPropertyName = "ponumber"
.Columns(1).Name = "requestedby"
.Columns(1).HeaderText = "Requested By"
.Columns(1).DataPropertyName = "requestedby"
.Columns(13).Name = "orderdate"
.Columns(13).HeaderText = "Order Date"
.Columns(13).DataPropertyName = "orderdate"
.Columns(2).Name = "Supplierid"
.Columns(2).HeaderText = "Supplier ID"
.Columns(2).DataPropertyName = "supplierid"
.Columns(3).Name = "suppliername"
.Columns(3).HeaderText = "Supplier Name"
.Columns(3).DataPropertyName = "suppliername"
.Columns(3).Width = "200" ' *** WRONG ***
.Columns(14).Name = "expecteddelivery"
.Columns(14).HeaderText = "Exp-Delivery"
.Columns(14).DataPropertyName = "expecteddelivery"
.Columns(4).Name = "quotationid"
.Columns(4).HeaderText = "Quotation ID"
.Columns(4).DataPropertyName = "quotationid"
.Columns(15).Name = "deliveryterm"
.Columns(15).HeaderText = "Delivery Term"
.Columns(15).DataPropertyName = "deliveryterm"
.Columns(16).Name = "paymentterm"
.Columns(16).HeaderText = "Payment Term"
.Columns(16).DataPropertyName = "paymentterm"
.Columns(19).Name = "priority"
.Columns(19).HeaderText = "Status"
.Columns(19).DataPropertyName = "priority"
.Columns(5).Name = "itemnumber"
.Columns(5).HeaderText = "Item Number"
.Columns(5).DataPropertyName = "itemnumber"
.Columns(6).Name = "barcode"
.Columns(6).HeaderText = "Barcode"
.Columns(6).DataPropertyName = "barcode"
.Columns(7).Name = "itemname"
.Columns(7).HeaderText = "Item Name"
.Columns(7).DataPropertyName = "itemname"
.Columns(8).Name = "itemdescription"
.Columns(8).HeaderText = "Item Description"
.Columns(8).DataPropertyName = "itemdescription"
.Columns(8).Width = "200" ' *** WRONG ***
.Columns(9).Name = "itemsizee"
.Columns(9).HeaderText = "Size"
.Columns(9).DataPropertyName = "itemsize"
.Columns(10).Name = "itemcolor"
.Columns(10).HeaderText = "Color"
.Columns(10).DataPropertyName = "itemcolor"
.Columns(11).Name = "unit"
.Columns(11).HeaderText = "Unit"
.Columns(11).DataPropertyName = "unit"
.Columns(12).Name = "qtytoorder"
.Columns(12).HeaderText = "Qty To Order"
.Columns(12).DataPropertyName = "qtytoorder"
.Columns(17).Name = "rate"
.Columns(17).HeaderText = "Rate"
.Columns(17).DataPropertyName = "rate"
.Columns(18).Name = "total"
.Columns(18).HeaderText = "Total"
.Columns(18).DataPropertyName = "total"
.DataSource = dt
End With
End Sub
End Class