G
Guest
Thanks for the Help in Advance!!
I am a beginner in VB.Net. I am trying to create a form which is displayed in a email for our customers to fill in a Request for quote. I would like them to type data into fields and have it added to the Datagrid.
I am constantly getting the error Column 'OALen' does not belong to table .
Any Ideas?
Public tblJobItems As New DataTable
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not (Page.IsPostBack) Then
'Sequence
Dim Sequence As DataColumn = New DataColumn
With Sequence
.DataType = System.Type.GetType("System.Int32")
.ColumnName = "Sequence"
.AllowDBNull = False
.ReadOnly = True
.AutoIncrement = True
End With
tblJobItems.Columns.Add(Sequence)
'Quantity
Dim Quantity As DataColumn = New DataColumn
With Quantity
.DataType = System.Type.GetType("System.Int32")
.ColumnName = "Quantity"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(Quantity)
'FamilyType
Dim FamilyType As DataColumn = New DataColumn
With FamilyType
.DataType = System.Type.GetType("System.String")
.ColumnName = "FamilyType"
.ReadOnly = False
.AutoIncrement = False
.Caption = "Truss Type"
End With
tblJobItems.Columns.Add(FamilyType)
' Over All Length
Dim OAL As DataColumn = New DataColumn
With OAL
.DataType = System.Type.GetType("System.String")
.ColumnName = "OALen"
.ReadOnly = False
.AutoIncrement = False
.Caption = "Over all Length"
End With
tblJobItems.Columns.Add(OAL)
'Heel
Dim Heel As DataColumn = New DataColumn
With Heel
.DataType = System.Type.GetType("System.String")
.ColumnName = "Heel"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(Heel)
'Item Description
Dim Description As DataColumn = New DataColumn
With Description
.DataType = System.Type.GetType("System.String")
.ColumnName = "Description"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(Description)
'Pitch
Dim Pitch As DataColumn = New DataColumn
With Pitch
.DataType = System.Type.GetType("System.String")
.ColumnName = "Pitch"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(Pitch)
'LOverHange
Dim LOverHang As DataColumn = New DataColumn
With LOverHang
.DataType = System.Type.GetType("System.String")
.ColumnName = "LOH"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(LOverHang)
'ROverHang
Dim ROverHang As DataColumn = New DataColumn
With ROverHang
.DataType = System.Type.GetType("System.String")
.ColumnName = "ROH"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(ROverHang)
'LCant
Dim LCant As DataColumn = New DataColumn
With LCant
.DataType = System.Type.GetType("System.String")
.ColumnName = "LCant"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(LCant)
'RCant
Dim RCant As DataColumn = New DataColumn
With RCant
.DataType = System.Type.GetType("System.String")
.ColumnName = "RCant"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(RCant)
'BearingSize
Dim BearingSize As DataColumn = New DataColumn
With BearingSize
.DataType = System.Type.GetType("System.String")
.ColumnName = "BearingSize"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(BearingSize)
'SpecialNotes
Dim SpecialNotes As DataColumn = New DataColumn
With SpecialNotes
.DataType = System.Type.GetType("System.String")
.ColumnName = "SpecialNotes"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(SpecialNotes)
' Create an array for DataColumn objects.
Dim keys(0) As DataColumn
keys(0) = Sequence
Dim PrimaryKeyColumns(0) As DataColumn
PrimaryKeyColumns(0) = tblJobItems.Columns("Sequence")
tblJobItems.PrimaryKey = PrimaryKeyColumns
End If
DataGrid1.DataSource = tblJobItems
DataGrid1.DataBind()
End Sub
Private Sub btnADDTrussItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnADDTrussItem.Click
'Insert new row into the dataset table
Dim dr As DataRow = tblJobItems.NewRow()
dr("OALen") = tbOAL.Text
dr("Heel") = ddlHeel.SelectedValue
tblJobItems.Rows.Add(dr)
'Refresh the grid
DataGrid1.EditItemIndex = -1
End Sub
I am a beginner in VB.Net. I am trying to create a form which is displayed in a email for our customers to fill in a Request for quote. I would like them to type data into fields and have it added to the Datagrid.
I am constantly getting the error Column 'OALen' does not belong to table .
Any Ideas?
Public tblJobItems As New DataTable
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not (Page.IsPostBack) Then
'Sequence
Dim Sequence As DataColumn = New DataColumn
With Sequence
.DataType = System.Type.GetType("System.Int32")
.ColumnName = "Sequence"
.AllowDBNull = False
.ReadOnly = True
.AutoIncrement = True
End With
tblJobItems.Columns.Add(Sequence)
'Quantity
Dim Quantity As DataColumn = New DataColumn
With Quantity
.DataType = System.Type.GetType("System.Int32")
.ColumnName = "Quantity"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(Quantity)
'FamilyType
Dim FamilyType As DataColumn = New DataColumn
With FamilyType
.DataType = System.Type.GetType("System.String")
.ColumnName = "FamilyType"
.ReadOnly = False
.AutoIncrement = False
.Caption = "Truss Type"
End With
tblJobItems.Columns.Add(FamilyType)
' Over All Length
Dim OAL As DataColumn = New DataColumn
With OAL
.DataType = System.Type.GetType("System.String")
.ColumnName = "OALen"
.ReadOnly = False
.AutoIncrement = False
.Caption = "Over all Length"
End With
tblJobItems.Columns.Add(OAL)
'Heel
Dim Heel As DataColumn = New DataColumn
With Heel
.DataType = System.Type.GetType("System.String")
.ColumnName = "Heel"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(Heel)
'Item Description
Dim Description As DataColumn = New DataColumn
With Description
.DataType = System.Type.GetType("System.String")
.ColumnName = "Description"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(Description)
'Pitch
Dim Pitch As DataColumn = New DataColumn
With Pitch
.DataType = System.Type.GetType("System.String")
.ColumnName = "Pitch"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(Pitch)
'LOverHange
Dim LOverHang As DataColumn = New DataColumn
With LOverHang
.DataType = System.Type.GetType("System.String")
.ColumnName = "LOH"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(LOverHang)
'ROverHang
Dim ROverHang As DataColumn = New DataColumn
With ROverHang
.DataType = System.Type.GetType("System.String")
.ColumnName = "ROH"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(ROverHang)
'LCant
Dim LCant As DataColumn = New DataColumn
With LCant
.DataType = System.Type.GetType("System.String")
.ColumnName = "LCant"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(LCant)
'RCant
Dim RCant As DataColumn = New DataColumn
With RCant
.DataType = System.Type.GetType("System.String")
.ColumnName = "RCant"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(RCant)
'BearingSize
Dim BearingSize As DataColumn = New DataColumn
With BearingSize
.DataType = System.Type.GetType("System.String")
.ColumnName = "BearingSize"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(BearingSize)
'SpecialNotes
Dim SpecialNotes As DataColumn = New DataColumn
With SpecialNotes
.DataType = System.Type.GetType("System.String")
.ColumnName = "SpecialNotes"
.ReadOnly = False
.AutoIncrement = False
End With
tblJobItems.Columns.Add(SpecialNotes)
' Create an array for DataColumn objects.
Dim keys(0) As DataColumn
keys(0) = Sequence
Dim PrimaryKeyColumns(0) As DataColumn
PrimaryKeyColumns(0) = tblJobItems.Columns("Sequence")
tblJobItems.PrimaryKey = PrimaryKeyColumns
End If
DataGrid1.DataSource = tblJobItems
DataGrid1.DataBind()
End Sub
Private Sub btnADDTrussItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnADDTrussItem.Click
'Insert new row into the dataset table
Dim dr As DataRow = tblJobItems.NewRow()
dr("OALen") = tbOAL.Text
dr("Heel") = ddlHeel.SelectedValue
tblJobItems.Rows.Add(dr)
'Refresh the grid
DataGrid1.EditItemIndex = -1
End Sub