mathieu_cupryk
asked on
Can I condense the following or how should I put it in its own sub routine.
Can I condense the following or how should I put it in its own sub routine.
Private Sub EditForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Verify for Null fields
If Not IsDBNull(_row.Account_Name ) Then
TextBox1.Text = _row.Account_Name
Else
TextBox1.Text = ""
End If
If Not IsDBNull(_row.Policy_Numbe r) Then
TextBox2.Text = _row.Policy_Number
Else
TextBox2.Text = ""
End If
If Not _row.IsOverride_Transactio n_CodeNull Then
TextBox3.Text = _row.Original_Transaction_ Code
Else
TextBox3.Text = ""
End If
If Not IsDBNull(_row._Trans__Eff_ _Date) Then
TextBox4.Text = _row._Trans__Eff__Date
Else
TextBox4.Text = ""
End If
If Not _row.IsOverride_ActionNull Then
TextBox5.Text = _row.Override_Action
Else
TextBox5.Text = ""
End If
If Not _row.Is_Override_New_Renew alNull Then
TextBox6.Text = _row._Override_New_Renewal
Else
TextBox6.Text = ""
End If
If Not _row.IsOverride_Transactio n_CodeNull Then
TextBox7.Text = _row.Override_Transaction_ Code
Else
TextBox7.Text = ""
End If
If Not IsDBNull(_row.UserId) Then
TextBox8.Text = _row.UserId
Else
TextBox8.Text = ""
End If
If Not IsDBNull(_row._Date) Then
TextBox9.Text = _row._Date
Else
TextBox9.Text = ""
End If
End Sub
Private Sub EditForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Verify for Null fields
If Not IsDBNull(_row.Account_Name
TextBox1.Text = _row.Account_Name
Else
TextBox1.Text = ""
End If
If Not IsDBNull(_row.Policy_Numbe
TextBox2.Text = _row.Policy_Number
Else
TextBox2.Text = ""
End If
If Not _row.IsOverride_Transactio
TextBox3.Text = _row.Original_Transaction_
Else
TextBox3.Text = ""
End If
If Not IsDBNull(_row._Trans__Eff_
TextBox4.Text = _row._Trans__Eff__Date
Else
TextBox4.Text = ""
End If
If Not _row.IsOverride_ActionNull
TextBox5.Text = _row.Override_Action
Else
TextBox5.Text = ""
End If
If Not _row.Is_Override_New_Renew
TextBox6.Text = _row._Override_New_Renewal
Else
TextBox6.Text = ""
End If
If Not _row.IsOverride_Transactio
TextBox7.Text = _row.Override_Transaction_
Else
TextBox7.Text = ""
End If
If Not IsDBNull(_row.UserId) Then
TextBox8.Text = _row.UserId
Else
TextBox8.Text = ""
End If
If Not IsDBNull(_row._Date) Then
TextBox9.Text = _row._Date
Else
TextBox9.Text = ""
End If
End Sub
ASKER
Exactly but it looks messy the EditForm?
I don't know it does not look messy to me. I would just leave it with the change I gave you. Maybe some one else will check in and have a better idea.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I like this way because I program in C# it looks clean.
But I get an error.
An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll
Additional information: Column 'Account_Name' does not belong to table AcctNames.
Private Sub FillTextBox(ByVal colName As String, ByVal tb As TextBox)
If Not IsDBNull(_row(colName)) Then
tb.Text = _row(colName)
Else
tb.Text = ""
End If
End Sub
Private Sub EditForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Verify for Null fields
FillTextBox("Account_Name" , TextBox1)
But I get an error.
An unhandled exception of type 'System.ArgumentException'
Additional information: Column 'Account_Name' does not belong to table AcctNames.
Private Sub FillTextBox(ByVal colName As String, ByVal tb As TextBox)
If Not IsDBNull(_row(colName)) Then
tb.Text = _row(colName)
Else
tb.Text = ""
End If
End Sub
Private Sub EditForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Verify for Null fields
FillTextBox("Account_Name"
I am not sure what is wrong with that if you are sure "Account_Name" is the exact column name in table "AcctNames".
Alternatively, you can use column number instead of column name:
Private Sub FillTextBox(ByVal colNo As Integer, ByVal tb As TextBox)
If Not IsDBNull(_row(colNo)) Then
tb.Text = _row(colNo)
End If
End Sub
Private Sub EditForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Verify for Null fields
FillTextBox(0, TextBox1)
But this way you have to make sure the column index in the datatable is the one you want to display in this textbox.
Private Sub FillTextBox(ByVal colNo As Integer, ByVal tb As TextBox)
If Not IsDBNull(_row(colNo)) Then
tb.Text = _row(colNo)
End If
End Sub
Private Sub EditForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Verify for Null fields
FillTextBox(0, TextBox1)
But this way you have to make sure the column index in the datatable is the one you want to display in this textbox.
ASKER
An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll
Additional information: Column '0' does not belong to table AcctNames.
This is problematic as well. Because I am linking the tables.
Additional information: Column '0' does not belong to table AcctNames.
This is problematic as well. Because I am linking the tables.
So what's in your dataset? How many tables do you have?
ASKER
I have three tables
To get the Account Name I need the Policy number and I use this to get the Account ID
Once I get the Account ID I use this to get the Account Name.
I have my main table which is my transoverride table that contains the policy number. From there I get the Account ID from table AccIDPolicyX and use this to get Account Name from AccNames table.
<?xml version="1.0" standalone="yes" ?>
<xs:schema id="DataSet1" targetNamespace="http://www.tempuri.org/DataSet1.xsd" xmlns:mstns="http://www.tempuri.org/DataSet1.xsd"
xmlns="http://www.tempuri.org/DataSet1.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas- microsoft- com:xml-ms data" attributeFormDefault="qual ified" elementFormDefault="qualif ied">
<xs:element name="DataSet1" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="AcctNames">
<xs:complexType>
<xs:sequence>
<xs:element name="Account_x0020_Name" type="xs:string" />
<xs:element name="Policy_x0020_Number" type="xs:string" />
<xs:element name="Original_x0020_Trans action_x00 20_Code" type="xs:string" />
<xs:element name="Trans._x0020_Eff._x0 020_Date" type="xs:dateTime" />
<xs:element name="Override_x0020_Actio n" type="xs:string" minOccurs="0" />
<xs:element name="Override_x0020_New_x 002F_Renew al" type="xs:string" minOccurs="0" />
<xs:element name="Override_x0020_Trans action_x00 20_Code" type="xs:string" minOccurs="0" />
<xs:element name="UserId" type="xs:string" />
<xs:element name="Date" type="xs:dateTime" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schem
To get the Account Name I need the Policy number and I use this to get the Account ID
Once I get the Account ID I use this to get the Account Name.
I have my main table which is my transoverride table that contains the policy number. From there I get the Account ID from table AccIDPolicyX and use this to get Account Name from AccNames table.
<?xml version="1.0" standalone="yes" ?>
<xs:schema id="DataSet1" targetNamespace="http://www.tempuri.org/DataSet1.xsd" xmlns:mstns="http://www.tempuri.org/DataSet1.xsd"
xmlns="http://www.tempuri.org/DataSet1.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-
<xs:element name="DataSet1" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="AcctNames">
<xs:complexType>
<xs:sequence>
<xs:element name="Account_x0020_Name" type="xs:string" />
<xs:element name="Policy_x0020_Number"
<xs:element name="Original_x0020_Trans
<xs:element name="Trans._x0020_Eff._x0
<xs:element name="Override_x0020_Actio
<xs:element name="Override_x0020_New_x
<xs:element name="Override_x0020_Trans
<xs:element name="UserId" type="xs:string" />
<xs:element name="Date" type="xs:dateTime" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schem
From the xsd code you posted, I can only tell there's one dataset called "DataSet1" and there's one datatable "AcctNames" in the dataset. Do you have other datasets or do you have other datatables in Dataset1 as you mentioned you have other two tables?
ASKER
I only have one dataset.
'------------------------- ---------- ---------- ---------- ---------- ---------- ---
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.1.4322.2032
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </autogenerated>
'------------------------- ---------- ---------- ---------- ---------- ---------- ---
Option Strict Off
Option Explicit On
Imports System
Imports System.Data
Imports System.Runtime.Serializati on
Imports System.Xml
<Serializable(), _
System.ComponentModel.Desi gnerCatego ryAttribut e("code"), _
System.Diagnostics.Debugge rStepThrou gh(), _
System.ComponentModel.Tool boxItem(tr ue)> _
Public Class DataSet1
Inherits DataSet
Private tableAcctNames As AcctNamesDataTable
Public Sub New()
MyBase.New
Me.InitClass
Dim schemaChangedHandler As System.ComponentModel.Coll ectionChan geEventHan dler = AddressOf Me.SchemaChanged
AddHandler Me.Tables.CollectionChange d, schemaChangedHandler
AddHandler Me.Relations.CollectionCha nged, schemaChangedHandler
End Sub
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New
Dim strSchema As String = CType(info.GetValue("XmlSc hema", GetType(System.String)),St ring)
If (Not (strSchema) Is Nothing) Then
Dim ds As DataSet = New DataSet
ds.ReadXmlSchema(New XmlTextReader(New System.IO.StringReader(str Schema)))
If (Not (ds.Tables("AcctNames")) Is Nothing) Then
Me.Tables.Add(New AcctNamesDataTable(ds.Tabl es("AcctNa mes")))
End If
Me.DataSetName = ds.DataSetName
Me.Prefix = ds.Prefix
Me.Namespace = ds.Namespace
Me.Locale = ds.Locale
Me.CaseSensitive = ds.CaseSensitive
Me.EnforceConstraints = ds.EnforceConstraints
Me.Merge(ds, false, System.Data.MissingSchemaA ction.Add)
Me.InitVars
Else
Me.InitClass
End If
Me.GetSerializationData(in fo, context)
Dim schemaChangedHandler As System.ComponentModel.Coll ectionChan geEventHan dler = AddressOf Me.SchemaChanged
AddHandler Me.Tables.CollectionChange d, schemaChangedHandler
AddHandler Me.Relations.CollectionCha nged, schemaChangedHandler
End Sub
<System.ComponentModel.Bro wsable(fal se), _
System.ComponentModel.Desi gnerSerial izationVis ibilityAtt ribute(Sys tem.Compon entModel.D esignerSer ialization Visibility .Content)> _
Public ReadOnly Property AcctNames As AcctNamesDataTable
Get
Return Me.tableAcctNames
End Get
End Property
Public Overrides Function Clone() As DataSet
Dim cln As DataSet1 = CType(MyBase.Clone,DataSet 1)
cln.InitVars
Return cln
End Function
Protected Overrides Function ShouldSerializeTables() As Boolean
Return false
End Function
Protected Overrides Function ShouldSerializeRelations() As Boolean
Return false
End Function
Protected Overrides Sub ReadXmlSerializable(ByVal reader As XmlReader)
Me.Reset
Dim ds As DataSet = New DataSet
ds.ReadXml(reader)
If (Not (ds.Tables("AcctNames")) Is Nothing) Then
Me.Tables.Add(New AcctNamesDataTable(ds.Tabl es("AcctNa mes")))
End If
Me.DataSetName = ds.DataSetName
Me.Prefix = ds.Prefix
Me.Namespace = ds.Namespace
Me.Locale = ds.Locale
Me.CaseSensitive = ds.CaseSensitive
Me.EnforceConstraints = ds.EnforceConstraints
Me.Merge(ds, false, System.Data.MissingSchemaA ction.Add)
Me.InitVars
End Sub
Protected Overrides Function GetSchemaSerializable() As System.Xml.Schema.XmlSchem a
Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream
Me.WriteXmlSchema(New XmlTextWriter(stream, Nothing))
stream.Position = 0
Return System.Xml.Schema.XmlSchem a.Read(New XmlTextReader(stream), Nothing)
End Function
Friend Sub InitVars()
Me.tableAcctNames = CType(Me.Tables("AcctNames "),AcctNam esDataTabl e)
If (Not (Me.tableAcctNames) Is Nothing) Then
Me.tableAcctNames.InitVars
End If
End Sub
Private Sub InitClass()
Me.DataSetName = "DataSet1"
Me.Prefix = ""
Me.Namespace = "http://www.tempuri.org/DataSet1.xsd"
Me.Locale = New System.Globalization.Cultu reInfo("en -US")
Me.CaseSensitive = false
Me.EnforceConstraints = true
Me.tableAcctNames = New AcctNamesDataTable
Me.Tables.Add(Me.tableAcct Names)
End Sub
Private Function ShouldSerializeAcctNames() As Boolean
Return false
End Function
Private Sub SchemaChanged(ByVal sender As Object, ByVal e As System.ComponentModel.Coll ectionChan geEventArg s)
If (e.Action = System.ComponentModel.Coll ectionChan geAction.R emove) Then
Me.InitVars
End If
End Sub
Public Delegate Sub AcctNamesRowChangeEventHan dler(ByVal sender As Object, ByVal e As AcctNamesRowChangeEvent)
<System.Diagnostics.Debugg erStepThro ugh()> _
Public Class AcctNamesDataTable
Inherits DataTable
Implements System.Collections.IEnumer able
Private columnAccount_Name As DataColumn
Private columnPolicy_Number As DataColumn
Private columnOriginal_Transaction _Code As DataColumn
Private column_Trans__Eff__Date As DataColumn
Private columnOverride_Action As DataColumn
Private column_Override_New_Renewa l As DataColumn
Private columnOverride_Transaction _Code As DataColumn
Private columnUserId As DataColumn
Private column_Date As DataColumn
Friend Sub New()
MyBase.New("AcctNames")
Me.InitClass
End Sub
Friend Sub New(ByVal table As DataTable)
MyBase.New(table.TableName )
If (table.CaseSensitive <> table.DataSet.CaseSensitiv e) Then
Me.CaseSensitive = table.CaseSensitive
End If
If (table.Locale.ToString <> table.DataSet.Locale.ToStr ing) Then
Me.Locale = table.Locale
End If
If (table.Namespace <> table.DataSet.Namespace) Then
Me.Namespace = table.Namespace
End If
Me.Prefix = table.Prefix
Me.MinimumCapacity = table.MinimumCapacity
Me.DisplayExpression = table.DisplayExpression
End Sub
<System.ComponentModel.Bro wsable(fal se)> _
Public ReadOnly Property Count As Integer
Get
Return Me.Rows.Count
End Get
End Property
Friend ReadOnly Property Account_NameColumn As DataColumn
Get
Return Me.columnAccount_Name
End Get
End Property
Friend ReadOnly Property Policy_NumberColumn As DataColumn
Get
Return Me.columnPolicy_Number
End Get
End Property
Friend ReadOnly Property Original_Transaction_CodeC olumn As DataColumn
Get
Return Me.columnOriginal_Transact ion_Code
End Get
End Property
Friend ReadOnly Property _Trans__Eff__DateColumn As DataColumn
Get
Return Me.column_Trans__Eff__Date
End Get
End Property
Friend ReadOnly Property Override_ActionColumn As DataColumn
Get
Return Me.columnOverride_Action
End Get
End Property
Friend ReadOnly Property _Override_New_RenewalColum n As DataColumn
Get
Return Me.column_Override_New_Ren ewal
End Get
End Property
Friend ReadOnly Property Override_Transaction_CodeC olumn As DataColumn
Get
Return Me.columnOverride_Transact ion_Code
End Get
End Property
Friend ReadOnly Property UserIdColumn As DataColumn
Get
Return Me.columnUserId
End Get
End Property
Friend ReadOnly Property _DateColumn As DataColumn
Get
Return Me.column_Date
End Get
End Property
Public Default ReadOnly Property Item(ByVal index As Integer) As AcctNamesRow
Get
Return CType(Me.Rows(index),AcctN amesRow)
End Get
End Property
Public Event AcctNamesRowChanged As AcctNamesRowChangeEventHan dler
Public Event AcctNamesRowChanging As AcctNamesRowChangeEventHan dler
Public Event AcctNamesRowDeleted As AcctNamesRowChangeEventHan dler
Public Event AcctNamesRowDeleting As AcctNamesRowChangeEventHan dler
Public Overloads Sub AddAcctNamesRow(ByVal row As AcctNamesRow)
Me.Rows.Add(row)
End Sub
Public Overloads Function AddAcctNamesRow(ByVal Account_Name As String, ByVal Policy_Number As String, ByVal Original_Transaction_Code As String, ByVal _Trans__Eff__Date As Date, ByVal Override_Action As String, ByVal _Override_New_Renewal As String, ByVal Override_Transaction_Code As String, ByVal UserId As String, ByVal _Date As Date) As AcctNamesRow
Dim rowAcctNamesRow As AcctNamesRow = CType(Me.NewRow,AcctNamesR ow)
rowAcctNamesRow.ItemArray = New Object() {Account_Name, Policy_Number, Original_Transaction_Code, _Trans__Eff__Date, Override_Action, _Override_New_Renewal, Override_Transaction_Code, UserId, _Date}
Me.Rows.Add(rowAcctNamesRo w)
Return rowAcctNamesRow
End Function
Public Function GetEnumerator() As System.Collections.IEnumer ator Implements System.Collections.IEnumer able.GetEn umerator
Return Me.Rows.GetEnumerator
End Function
Public Overrides Function Clone() As DataTable
Dim cln As AcctNamesDataTable = CType(MyBase.Clone,AcctNam esDataTabl e)
cln.InitVars
Return cln
End Function
Protected Overrides Function CreateInstance() As DataTable
Return New AcctNamesDataTable
End Function
Friend Sub InitVars()
Me.columnAccount_Name = Me.Columns("Account Name")
Me.columnPolicy_Number = Me.Columns("Policy Number")
Me.columnOriginal_Transact ion_Code = Me.Columns("Original Transaction Code")
Me.column_Trans__Eff__Date = Me.Columns("Trans. Eff. Date")
Me.columnOverride_Action = Me.Columns("Override Action")
Me.column_Override_New_Ren ewal = Me.Columns("Override New/Renewal")
Me.columnOverride_Transact ion_Code = Me.Columns("Override Transaction Code")
Me.columnUserId = Me.Columns("UserId")
Me.column_Date = Me.Columns("Date")
End Sub
Private Sub InitClass()
Me.columnAccount_Name = New DataColumn("Account Name", GetType(System.String), Nothing, System.Data.MappingType.El ement)
Me.Columns.Add(Me.columnAc count_Name )
Me.columnPolicy_Number = New DataColumn("Policy Number", GetType(System.String), Nothing, System.Data.MappingType.El ement)
Me.Columns.Add(Me.columnPo licy_Numbe r)
Me.columnOriginal_Transact ion_Code = New DataColumn("Original Transaction Code", GetType(System.String), Nothing, System.Data.MappingType.El ement)
Me.Columns.Add(Me.columnOr iginal_Tra nsaction_C ode)
Me.column_Trans__Eff__Date = New DataColumn("Trans. Eff. Date", GetType(System.DateTime), Nothing, System.Data.MappingType.El ement)
Me.Columns.Add(Me.column_T rans__Eff_ _Date)
Me.columnOverride_Action = New DataColumn("Override Action", GetType(System.String), Nothing, System.Data.MappingType.El ement)
Me.Columns.Add(Me.columnOv erride_Act ion)
Me.column_Override_New_Ren ewal = New DataColumn("Override New/Renewal", GetType(System.String), Nothing, System.Data.MappingType.El ement)
Me.Columns.Add(Me.column_O verride_Ne w_Renewal)
Me.columnOverride_Transact ion_Code = New DataColumn("Override Transaction Code", GetType(System.String), Nothing, System.Data.MappingType.El ement)
Me.Columns.Add(Me.columnOv erride_Tra nsaction_C ode)
Me.columnUserId = New DataColumn("UserId", GetType(System.String), Nothing, System.Data.MappingType.El ement)
Me.Columns.Add(Me.columnUs erId)
Me.column_Date = New DataColumn("Date", GetType(System.DateTime), Nothing, System.Data.MappingType.El ement)
Me.Columns.Add(Me.column_D ate)
Me.columnAccount_Name.Allo wDBNull = false
Me.columnPolicy_Number.All owDBNull = false
Me.columnOriginal_Transact ion_Code.A llowDBNull = false
Me.column_Trans__Eff__Date .AllowDBNu ll = false
Me.columnUserId.AllowDBNul l = false
Me.column_Date.AllowDBNull = false
End Sub
Public Function NewAcctNamesRow() As AcctNamesRow
Return CType(Me.NewRow,AcctNamesR ow)
End Function
Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
Return New AcctNamesRow(builder)
End Function
Protected Overrides Function GetRowType() As System.Type
Return GetType(AcctNamesRow)
End Function
Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanged(e)
If (Not (Me.AcctNamesRowChangedEve nt) Is Nothing) Then
RaiseEvent AcctNamesRowChanged(Me, New AcctNamesRowChangeEvent(CT ype(e.Row, AcctNamesR ow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanging(e)
If (Not (Me.AcctNamesRowChangingEv ent) Is Nothing) Then
RaiseEvent AcctNamesRowChanging(Me, New AcctNamesRowChangeEvent(CT ype(e.Row, AcctNamesR ow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleted(e)
If (Not (Me.AcctNamesRowDeletedEve nt) Is Nothing) Then
RaiseEvent AcctNamesRowDeleted(Me, New AcctNamesRowChangeEvent(CT ype(e.Row, AcctNamesR ow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleting(e)
If (Not (Me.AcctNamesRowDeletingEv ent) Is Nothing) Then
RaiseEvent AcctNamesRowDeleting(Me, New AcctNamesRowChangeEvent(CT ype(e.Row, AcctNamesR ow), e.Action))
End If
End Sub
Public Sub RemoveAcctNamesRow(ByVal row As AcctNamesRow)
Me.Rows.Remove(row)
End Sub
End Class
<System.Diagnostics.Debugg erStepThro ugh()> _
Public Class AcctNamesRow
Inherits DataRow
Private tableAcctNames As AcctNamesDataTable
Friend Sub New(ByVal rb As DataRowBuilder)
MyBase.New(rb)
Me.tableAcctNames = CType(Me.Table,AcctNamesDa taTable)
End Sub
Public Property Account_Name As String
Get
Return CType(Me(Me.tableAcctNames .Account_N ameColumn) ,String)
End Get
Set
Me(Me.tableAcctNames.Accou nt_NameCol umn) = value
End Set
End Property
Public Property Policy_Number As String
Get
Return CType(Me(Me.tableAcctNames .Policy_Nu mberColumn ),String)
End Get
Set
Me(Me.tableAcctNames.Polic y_NumberCo lumn) = value
End Set
End Property
Public Property Original_Transaction_Code As String
Get
Return CType(Me(Me.tableAcctNames .Original_ Transactio n_CodeColu mn),String )
End Get
Set
Me(Me.tableAcctNames.Origi nal_Transa ction_Code Column) = value
End Set
End Property
Public Property _Trans__Eff__Date As Date
Get
Return CType(Me(Me.tableAcctNames ._Trans__E ff__DateCo lumn),Date )
End Get
Set
Me(Me.tableAcctNames._Tran s__Eff__Da teColumn) = value
End Set
End Property
Public Property Override_Action As String
Get
Try
Return CType(Me(Me.tableAcctNames .Override_ ActionColu mn),String )
Catch e As InvalidCastException
Throw New StrongTypingException("Can not get value because it is DBNull.", e)
End Try
End Get
Set
Me(Me.tableAcctNames.Overr ide_Action Column) = value
End Set
End Property
Public Property _Override_New_Renewal As String
Get
Try
Return CType(Me(Me.tableAcctNames ._Override _New_Renew alColumn), String)
Catch e As InvalidCastException
Throw New StrongTypingException("Can not get value because it is DBNull.", e)
End Try
End Get
Set
Me(Me.tableAcctNames._Over ride_New_R enewalColu mn) = value
End Set
End Property
Public Property Override_Transaction_Code As String
Get
Try
Return CType(Me(Me.tableAcctNames .Override_ Transactio n_CodeColu mn),String )
Catch e As InvalidCastException
Throw New StrongTypingException("Can not get value because it is DBNull.", e)
End Try
End Get
Set
Me(Me.tableAcctNames.Overr ide_Transa ction_Code Column) = value
End Set
End Property
Public Property UserId As String
Get
Return CType(Me(Me.tableAcctNames .UserIdCol umn),Strin g)
End Get
Set
Me(Me.tableAcctNames.UserI dColumn) = value
End Set
End Property
Public Property _Date As Date
Get
Return CType(Me(Me.tableAcctNames ._DateColu mn),Date)
End Get
Set
Me(Me.tableAcctNames._Date Column) = value
End Set
End Property
Public Function IsOverride_ActionNull() As Boolean
Return Me.IsNull(Me.tableAcctName s.Override _ActionCol umn)
End Function
Public Sub SetOverride_ActionNull()
Me(Me.tableAcctNames.Overr ide_Action Column) = System.Convert.DBNull
End Sub
Public Function Is_Override_New_RenewalNul l() As Boolean
Return Me.IsNull(Me.tableAcctName s._Overrid e_New_Rene walColumn)
End Function
Public Sub Set_Override_New_RenewalNu ll()
Me(Me.tableAcctNames._Over ride_New_R enewalColu mn) = System.Convert.DBNull
End Sub
Public Function IsOverride_Transaction_Cod eNull() As Boolean
Return Me.IsNull(Me.tableAcctName s.Override _Transacti on_CodeCol umn)
End Function
Public Sub SetOverride_Transaction_Co deNull()
Me(Me.tableAcctNames.Overr ide_Transa ction_Code Column) = System.Convert.DBNull
End Sub
End Class
<System.Diagnostics.Debugg erStepThro ugh()> _
Public Class AcctNamesRowChangeEvent
Inherits EventArgs
Private eventRow As AcctNamesRow
Private eventAction As DataRowAction
Public Sub New(ByVal row As AcctNamesRow, ByVal action As DataRowAction)
MyBase.New
Me.eventRow = row
Me.eventAction = action
End Sub
Public ReadOnly Property Row As AcctNamesRow
Get
Return Me.eventRow
End Get
End Property
Public ReadOnly Property Action As DataRowAction
Get
Return Me.eventAction
End Get
End Property
End Class
End Class
'-------------------------
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.1.4322.2032
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </autogenerated>
'-------------------------
Option Strict Off
Option Explicit On
Imports System
Imports System.Data
Imports System.Runtime.Serializati
Imports System.Xml
<Serializable(), _
System.ComponentModel.Desi
System.Diagnostics.Debugge
System.ComponentModel.Tool
Public Class DataSet1
Inherits DataSet
Private tableAcctNames As AcctNamesDataTable
Public Sub New()
MyBase.New
Me.InitClass
Dim schemaChangedHandler As System.ComponentModel.Coll
AddHandler Me.Tables.CollectionChange
AddHandler Me.Relations.CollectionCha
End Sub
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
MyBase.New
Dim strSchema As String = CType(info.GetValue("XmlSc
If (Not (strSchema) Is Nothing) Then
Dim ds As DataSet = New DataSet
ds.ReadXmlSchema(New XmlTextReader(New System.IO.StringReader(str
If (Not (ds.Tables("AcctNames")) Is Nothing) Then
Me.Tables.Add(New AcctNamesDataTable(ds.Tabl
End If
Me.DataSetName = ds.DataSetName
Me.Prefix = ds.Prefix
Me.Namespace = ds.Namespace
Me.Locale = ds.Locale
Me.CaseSensitive = ds.CaseSensitive
Me.EnforceConstraints = ds.EnforceConstraints
Me.Merge(ds, false, System.Data.MissingSchemaA
Me.InitVars
Else
Me.InitClass
End If
Me.GetSerializationData(in
Dim schemaChangedHandler As System.ComponentModel.Coll
AddHandler Me.Tables.CollectionChange
AddHandler Me.Relations.CollectionCha
End Sub
<System.ComponentModel.Bro
System.ComponentModel.Desi
Public ReadOnly Property AcctNames As AcctNamesDataTable
Get
Return Me.tableAcctNames
End Get
End Property
Public Overrides Function Clone() As DataSet
Dim cln As DataSet1 = CType(MyBase.Clone,DataSet
cln.InitVars
Return cln
End Function
Protected Overrides Function ShouldSerializeTables() As Boolean
Return false
End Function
Protected Overrides Function ShouldSerializeRelations()
Return false
End Function
Protected Overrides Sub ReadXmlSerializable(ByVal reader As XmlReader)
Me.Reset
Dim ds As DataSet = New DataSet
ds.ReadXml(reader)
If (Not (ds.Tables("AcctNames")) Is Nothing) Then
Me.Tables.Add(New AcctNamesDataTable(ds.Tabl
End If
Me.DataSetName = ds.DataSetName
Me.Prefix = ds.Prefix
Me.Namespace = ds.Namespace
Me.Locale = ds.Locale
Me.CaseSensitive = ds.CaseSensitive
Me.EnforceConstraints = ds.EnforceConstraints
Me.Merge(ds, false, System.Data.MissingSchemaA
Me.InitVars
End Sub
Protected Overrides Function GetSchemaSerializable() As System.Xml.Schema.XmlSchem
Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream
Me.WriteXmlSchema(New XmlTextWriter(stream, Nothing))
stream.Position = 0
Return System.Xml.Schema.XmlSchem
End Function
Friend Sub InitVars()
Me.tableAcctNames = CType(Me.Tables("AcctNames
If (Not (Me.tableAcctNames) Is Nothing) Then
Me.tableAcctNames.InitVars
End If
End Sub
Private Sub InitClass()
Me.DataSetName = "DataSet1"
Me.Prefix = ""
Me.Namespace = "http://www.tempuri.org/DataSet1.xsd"
Me.Locale = New System.Globalization.Cultu
Me.CaseSensitive = false
Me.EnforceConstraints = true
Me.tableAcctNames = New AcctNamesDataTable
Me.Tables.Add(Me.tableAcct
End Sub
Private Function ShouldSerializeAcctNames()
Return false
End Function
Private Sub SchemaChanged(ByVal sender As Object, ByVal e As System.ComponentModel.Coll
If (e.Action = System.ComponentModel.Coll
Me.InitVars
End If
End Sub
Public Delegate Sub AcctNamesRowChangeEventHan
<System.Diagnostics.Debugg
Public Class AcctNamesDataTable
Inherits DataTable
Implements System.Collections.IEnumer
Private columnAccount_Name As DataColumn
Private columnPolicy_Number As DataColumn
Private columnOriginal_Transaction
Private column_Trans__Eff__Date As DataColumn
Private columnOverride_Action As DataColumn
Private column_Override_New_Renewa
Private columnOverride_Transaction
Private columnUserId As DataColumn
Private column_Date As DataColumn
Friend Sub New()
MyBase.New("AcctNames")
Me.InitClass
End Sub
Friend Sub New(ByVal table As DataTable)
MyBase.New(table.TableName
If (table.CaseSensitive <> table.DataSet.CaseSensitiv
Me.CaseSensitive = table.CaseSensitive
End If
If (table.Locale.ToString <> table.DataSet.Locale.ToStr
Me.Locale = table.Locale
End If
If (table.Namespace <> table.DataSet.Namespace) Then
Me.Namespace = table.Namespace
End If
Me.Prefix = table.Prefix
Me.MinimumCapacity = table.MinimumCapacity
Me.DisplayExpression = table.DisplayExpression
End Sub
<System.ComponentModel.Bro
Public ReadOnly Property Count As Integer
Get
Return Me.Rows.Count
End Get
End Property
Friend ReadOnly Property Account_NameColumn As DataColumn
Get
Return Me.columnAccount_Name
End Get
End Property
Friend ReadOnly Property Policy_NumberColumn As DataColumn
Get
Return Me.columnPolicy_Number
End Get
End Property
Friend ReadOnly Property Original_Transaction_CodeC
Get
Return Me.columnOriginal_Transact
End Get
End Property
Friend ReadOnly Property _Trans__Eff__DateColumn As DataColumn
Get
Return Me.column_Trans__Eff__Date
End Get
End Property
Friend ReadOnly Property Override_ActionColumn As DataColumn
Get
Return Me.columnOverride_Action
End Get
End Property
Friend ReadOnly Property _Override_New_RenewalColum
Get
Return Me.column_Override_New_Ren
End Get
End Property
Friend ReadOnly Property Override_Transaction_CodeC
Get
Return Me.columnOverride_Transact
End Get
End Property
Friend ReadOnly Property UserIdColumn As DataColumn
Get
Return Me.columnUserId
End Get
End Property
Friend ReadOnly Property _DateColumn As DataColumn
Get
Return Me.column_Date
End Get
End Property
Public Default ReadOnly Property Item(ByVal index As Integer) As AcctNamesRow
Get
Return CType(Me.Rows(index),AcctN
End Get
End Property
Public Event AcctNamesRowChanged As AcctNamesRowChangeEventHan
Public Event AcctNamesRowChanging As AcctNamesRowChangeEventHan
Public Event AcctNamesRowDeleted As AcctNamesRowChangeEventHan
Public Event AcctNamesRowDeleting As AcctNamesRowChangeEventHan
Public Overloads Sub AddAcctNamesRow(ByVal row As AcctNamesRow)
Me.Rows.Add(row)
End Sub
Public Overloads Function AddAcctNamesRow(ByVal Account_Name As String, ByVal Policy_Number As String, ByVal Original_Transaction_Code As String, ByVal _Trans__Eff__Date As Date, ByVal Override_Action As String, ByVal _Override_New_Renewal As String, ByVal Override_Transaction_Code As String, ByVal UserId As String, ByVal _Date As Date) As AcctNamesRow
Dim rowAcctNamesRow As AcctNamesRow = CType(Me.NewRow,AcctNamesR
rowAcctNamesRow.ItemArray = New Object() {Account_Name, Policy_Number, Original_Transaction_Code,
Me.Rows.Add(rowAcctNamesRo
Return rowAcctNamesRow
End Function
Public Function GetEnumerator() As System.Collections.IEnumer
Return Me.Rows.GetEnumerator
End Function
Public Overrides Function Clone() As DataTable
Dim cln As AcctNamesDataTable = CType(MyBase.Clone,AcctNam
cln.InitVars
Return cln
End Function
Protected Overrides Function CreateInstance() As DataTable
Return New AcctNamesDataTable
End Function
Friend Sub InitVars()
Me.columnAccount_Name = Me.Columns("Account Name")
Me.columnPolicy_Number = Me.Columns("Policy Number")
Me.columnOriginal_Transact
Me.column_Trans__Eff__Date
Me.columnOverride_Action = Me.Columns("Override Action")
Me.column_Override_New_Ren
Me.columnOverride_Transact
Me.columnUserId = Me.Columns("UserId")
Me.column_Date = Me.Columns("Date")
End Sub
Private Sub InitClass()
Me.columnAccount_Name = New DataColumn("Account Name", GetType(System.String), Nothing, System.Data.MappingType.El
Me.Columns.Add(Me.columnAc
Me.columnPolicy_Number = New DataColumn("Policy Number", GetType(System.String), Nothing, System.Data.MappingType.El
Me.Columns.Add(Me.columnPo
Me.columnOriginal_Transact
Me.Columns.Add(Me.columnOr
Me.column_Trans__Eff__Date
Me.Columns.Add(Me.column_T
Me.columnOverride_Action = New DataColumn("Override Action", GetType(System.String), Nothing, System.Data.MappingType.El
Me.Columns.Add(Me.columnOv
Me.column_Override_New_Ren
Me.Columns.Add(Me.column_O
Me.columnOverride_Transact
Me.Columns.Add(Me.columnOv
Me.columnUserId = New DataColumn("UserId", GetType(System.String), Nothing, System.Data.MappingType.El
Me.Columns.Add(Me.columnUs
Me.column_Date = New DataColumn("Date", GetType(System.DateTime), Nothing, System.Data.MappingType.El
Me.Columns.Add(Me.column_D
Me.columnAccount_Name.Allo
Me.columnPolicy_Number.All
Me.columnOriginal_Transact
Me.column_Trans__Eff__Date
Me.columnUserId.AllowDBNul
Me.column_Date.AllowDBNull
End Sub
Public Function NewAcctNamesRow() As AcctNamesRow
Return CType(Me.NewRow,AcctNamesR
End Function
Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
Return New AcctNamesRow(builder)
End Function
Protected Overrides Function GetRowType() As System.Type
Return GetType(AcctNamesRow)
End Function
Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanged(e)
If (Not (Me.AcctNamesRowChangedEve
RaiseEvent AcctNamesRowChanged(Me, New AcctNamesRowChangeEvent(CT
End If
End Sub
Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanging(e)
If (Not (Me.AcctNamesRowChangingEv
RaiseEvent AcctNamesRowChanging(Me, New AcctNamesRowChangeEvent(CT
End If
End Sub
Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleted(e)
If (Not (Me.AcctNamesRowDeletedEve
RaiseEvent AcctNamesRowDeleted(Me, New AcctNamesRowChangeEvent(CT
End If
End Sub
Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleting(e)
If (Not (Me.AcctNamesRowDeletingEv
RaiseEvent AcctNamesRowDeleting(Me, New AcctNamesRowChangeEvent(CT
End If
End Sub
Public Sub RemoveAcctNamesRow(ByVal row As AcctNamesRow)
Me.Rows.Remove(row)
End Sub
End Class
<System.Diagnostics.Debugg
Public Class AcctNamesRow
Inherits DataRow
Private tableAcctNames As AcctNamesDataTable
Friend Sub New(ByVal rb As DataRowBuilder)
MyBase.New(rb)
Me.tableAcctNames = CType(Me.Table,AcctNamesDa
End Sub
Public Property Account_Name As String
Get
Return CType(Me(Me.tableAcctNames
End Get
Set
Me(Me.tableAcctNames.Accou
End Set
End Property
Public Property Policy_Number As String
Get
Return CType(Me(Me.tableAcctNames
End Get
Set
Me(Me.tableAcctNames.Polic
End Set
End Property
Public Property Original_Transaction_Code As String
Get
Return CType(Me(Me.tableAcctNames
End Get
Set
Me(Me.tableAcctNames.Origi
End Set
End Property
Public Property _Trans__Eff__Date As Date
Get
Return CType(Me(Me.tableAcctNames
End Get
Set
Me(Me.tableAcctNames._Tran
End Set
End Property
Public Property Override_Action As String
Get
Try
Return CType(Me(Me.tableAcctNames
Catch e As InvalidCastException
Throw New StrongTypingException("Can
End Try
End Get
Set
Me(Me.tableAcctNames.Overr
End Set
End Property
Public Property _Override_New_Renewal As String
Get
Try
Return CType(Me(Me.tableAcctNames
Catch e As InvalidCastException
Throw New StrongTypingException("Can
End Try
End Get
Set
Me(Me.tableAcctNames._Over
End Set
End Property
Public Property Override_Transaction_Code As String
Get
Try
Return CType(Me(Me.tableAcctNames
Catch e As InvalidCastException
Throw New StrongTypingException("Can
End Try
End Get
Set
Me(Me.tableAcctNames.Overr
End Set
End Property
Public Property UserId As String
Get
Return CType(Me(Me.tableAcctNames
End Get
Set
Me(Me.tableAcctNames.UserI
End Set
End Property
Public Property _Date As Date
Get
Return CType(Me(Me.tableAcctNames
End Get
Set
Me(Me.tableAcctNames._Date
End Set
End Property
Public Function IsOverride_ActionNull() As Boolean
Return Me.IsNull(Me.tableAcctName
End Function
Public Sub SetOverride_ActionNull()
Me(Me.tableAcctNames.Overr
End Sub
Public Function Is_Override_New_RenewalNul
Return Me.IsNull(Me.tableAcctName
End Function
Public Sub Set_Override_New_RenewalNu
Me(Me.tableAcctNames._Over
End Sub
Public Function IsOverride_Transaction_Cod
Return Me.IsNull(Me.tableAcctName
End Function
Public Sub SetOverride_Transaction_Co
Me(Me.tableAcctNames.Overr
End Sub
End Class
<System.Diagnostics.Debugg
Public Class AcctNamesRowChangeEvent
Inherits EventArgs
Private eventRow As AcctNamesRow
Private eventAction As DataRowAction
Public Sub New(ByVal row As AcctNamesRow, ByVal action As DataRowAction)
MyBase.New
Me.eventRow = row
Me.eventAction = action
End Sub
Public ReadOnly Property Row As AcctNamesRow
Get
Return Me.eventRow
End Get
End Property
Public ReadOnly Property Action As DataRowAction
Get
Return Me.eventAction
End Get
End Property
End Class
End Class
Seeming that this is done during the EditForm_Load event if your textbox's were cleared of text at Design time then there is no need to clear them again. As to putting this code to its own sub if this is the only time you execute this code just leave it where it is.
Private Sub EditForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Verify for Null fields
If Not IsDBNull(_row.Account_Name
TextBox1.Text = _row.Account_Name
End If
If Not IsDBNull(_row.Policy_Numbe
TextBox2.Text = _row.Policy_Number
End If
If Not _row.IsOverride_Transactio
TextBox3.Text = _row.Original_Transaction_
End If
If Not IsDBNull(_row._Trans__Eff_
TextBox4.Text = _row._Trans__Eff__Date
End If
If Not _row.IsOverride_ActionNull
TextBox5.Text = _row.Override_Action
End If
If Not _row.Is_Override_New_Renew
TextBox6.Text = _row._Override_New_Renewal
End If
If Not _row.IsOverride_Transactio
TextBox7.Text = _row.Override_Transaction_
End If
If Not IsDBNull(_row.UserId) Then
TextBox8.Text = _row.UserId
End If
If Not IsDBNull(_row._Date) Then
TextBox9.Text = _row._Date
End If
End Sub