Results 1 to 4 of 4

Thread: DataTable creator

  1. #1

    Thread Starter
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,684

    DataTable creator

    The purpose for this simple utility is to create DataTable Columns and avoid having to type in all the properties associated with creating a DataTable. I kept it simple which means use it to create the columns, do not try it fool it as there is no exception handling.

    The first iteration created columns, current iteration permits simple DataColumn Expressions with minimal assertion. Currently working on adding functionality to add mocked data with common fields such as first/last name, address along with mocked credit card numbers and mocked SSN.

    Requires VS2012 but if you are comfortable with how to downgrade to VS2010 the code is compatible as are the forms.

    MSDN article with VS2012 solution. I did not upload it here as a) wanted to maintain the code in one location b) new changes are coming and will post them here.

    Name:  G1.jpg
Views: 486
Size:  63.3 KB
    Last edited by kareninstructor; Aug 17th, 2013 at 11:02 AM. Reason: Revised screenshot

  2. #2

    Re: DataTable creator

    Pretty nifty! Replying so I can easily find it when I get home.

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: DataTable creator

    I usually jsut subscribe to threads for that reason... good stuff... apparently I gotta spread the love a little more though...


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,684

    Re: DataTable creator

    I just updated the utility to include an option to create one to four events (common events used).

    Example that created events and one column expression
    Code:
    Public Module DataTable_GeneratedCode
        Public Sub Generated()
            Dim dt As New DataTable With {.TableName = "MyTable"}
            dt.Columns.Add(New DataColumn With {.ColumnName = "Identifier", .DataType = GetType(Int32),
                                                .AutoIncrement = True, .AutoIncrementSeed = 1})
            dt.Columns.Add(New DataColumn With {.ColumnName = "FirstName", .DataType = GetType(String)})
            dt.Columns.Add(New DataColumn With {.ColumnName = "LastName", .DataType = GetType(String)})
            dt.Columns.Add(New DataColumn With {.ColumnName = "FullName", .DataType = GetType(String),
                                                .Expression = "FirstName + ' ' + LastName"})
            dt.Columns.Add(New DataColumn With {.ColumnName = "Country", .DataType = GetType(String)})
    
            AddHandler dt.ColumnChanged, AddressOf dt_ColumnChanged
            AddHandler dt.ColumnChanging, AddressOf dt_ColumnChanging
            AddHandler dt.RowChanging, AddressOf dt_RowChanging
    
        End Sub
        Private Sub dt_ColumnChanged(sender As Object, e As DataColumnChangeEventArgs)
    
        End Sub
        Private Sub dt_ColumnChanging(sender As Object, e As DataColumnChangeEventArgs)
    
        End Sub
        Private Sub dt_RowChanging(sender As Object, e As DataRowChangeEventArgs)
    
        End Sub
    End Module
    Last edited by kareninstructor; Aug 18th, 2013 at 06:57 PM. Reason: Updated code block

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width