Results 1 to 3 of 3

Thread: [Resolved] Add DataRow to DataTable...

Threaded View

  1. #1

    Thread Starter
    Fanatic Member Redth's Avatar
    Join Date
    May 2001
    Location
    Ontario, Canada
    Posts
    551

    [Resolved] Add DataRow to DataTable...

    Hello, i'm trying to pass back a DataTable through a function..

    i've created my datatable no problems, setup all my columns, but now i'm trying to add a row to the datatable.. it's not going so smooth...

    here's the code i'm attempting...

    VB Code:
    1. 'Create our datatable column structure
    2.             dtblAccount.Columns.Add("ID", GetType(Integer))
    3.             dtblAccount.Columns.Add("UserName", GetType(String))
    4.             dtblAccount.Columns.Add("UserPass", GetType(String))
    5.             dtblAccount.Columns.Add("Email", GetType(String))
    6.             dtblAccount.Columns.Add("FirstName", GetType(String))
    7.             dtblAccount.Columns.Add("LastName", GetType(String))
    8.             dtblAccount.Columns.Add("BusinessName", GetType(String))
    9.             dtblAccount.Columns.Add("BusinessDesc", GetType(String))
    10.             dtblAccount.Columns.Add("Phone", GetType(String))
    11.             dtblAccount.Columns.Add("Fax", GetType(String))
    12.             dtblAccount.Columns.Add("Address", GetType(String))
    13.             dtblAccount.Columns.Add("City", GetType(String))
    14.             dtblAccount.Columns.Add("State", GetType(String))
    15.             dtblAccount.Columns.Add("ZipCode", GetType(String))
    16.             dtblAccount.Columns.Add("Country", GetType(String))
    17.             dtblAccount.Columns.Add("ValidationCode", GetType(String))
    18.             dtblAccount.Columns.Add("Validated", GetType(Integer))
    19.             dtblAccount.Columns.Add("WebsiteURL", GetType(String))
    20.             dtblAccount.Columns.Add("DateRegistered", GetType(DateTime))
    21.  
    22.             'Create a DataRow, filled with the proper column contents
    23.        
    24.     dRow("ID") = objDS("ID") & ""
    25.             dRow("UserName") = objDS("UserName") & ""
    26.             dRow("UserPass") = objDS("UserPass") & ""
    27.             dRow("Email") = objDS("Email") & ""
    28.             dRow("FirstName") = objDS("FirstName") & ""
    29.             dRow("LastName") = objDS("LastName") & ""
    30.             dRow("BusinessName") = objDS("BusinessName") & ""
    31.             dRow("BusinessDesc") = objDS("BusinessDesc") & ""
    32.             dRow("Phone") = objDS("Phone") & ""
    33.             dRow("Fax") = objDS("Fax") & ""
    34.             dRow("Address") = objDS("Address") & ""
    35.             dRow("City") = objDS("City") & ""
    36.             dRow("State") = objDS("State") & ""
    37.             dRow("ZipCode") = objDS("ZipCode") & ""
    38.             dRow("Country") = objDS("Country") & ""
    39.             dRow("ValidationCode") = objDS("ValidationCode") & ""
    40.             dRow("Validated") = objDS("Validated") & ""
    41.             dRow("WebsiteURL") = objDS("WebsiteURL") & ""
    42.             dRow("DateRegistered") = objDS("DateRegistered") & ""
    43.  
    44.             'Add drow, the row we just created, to the datatable
    45.             dtblAccount.Rows.Add(dRow)

    Now, obviously that doesn't work...

    why? because how does dRow (which is declared as a DataRow) know what column structure to follow? it doesn't...

    dtblAccount is declared as a DataTable btw...

    how can i go about this? thanks for the help!
    Last edited by Redth; Dec 2nd, 2002 at 11:16 PM.

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