DataTable creator-VBForums
Results 1 to 4 of 4

Thread: DataTable creator

  1. #1

    Thread Starter
    PowerPoster kevininstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    5,790

    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: 152
Size:  63.3 KB

  2. #2
    PowerPoster formlesstree4's Avatar
    Join Date
    Jun 2008
    Location
    On the Internet
    Posts
    3,249

    Re: DataTable creator

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

  3. #3
    PowerPoster
    Join Date
    May 2002
    Posts
    25,459

    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
    PowerPoster kevininstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    5,790

    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

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.