insert values to array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nilu12345
    New Member
    • Jun 2007
    • 1

    #1

    insert values to array

    i want to insert selected values from SQL to two dimensional array
  • dip_developer
    Recognized Expert Contributor
    • Aug 2006
    • 648

    #2
    Originally posted by nilu12345
    i want to insert selected values from SQL to two dimensional array
    Similar to declaring variables, an array is declared with a Dim statement. The array name is followed by a pair of parentheses to indicate an array variable. For a single dimension array (one column) the parentheses are empty; for a multidimensiona l array commas are used for each additional column. An array is typed in the same way as variables to declare the type of data to occupy the array. The following statements declare a single- and a two-dimensional array, respectively, each of which contain string data.

    Dim Letters() As String
    Dim Letters(,) As String

    When arrays are declared, they do not have physical sizes. They have dimensions, but the number of rows and columns is unknown. If you know in advance the number of values that will occupy an array, you can include the size as part of its declaration. The two previous Letters arrays can be declared as

    Dim Letters(4) As String
    Dim Letters(4,1) As String

    to indicate an array with 5 rows, and an array with 5 rows and 2 columns, respectively. Note that, because array indexing begins with 0, the dimensions of an array are always 1 less than the actual number of array elements. You can determine the actual size of an array through the arrayName.Length property, which returns the total number of elements in the array.

    if You have a Dataset or Datareader returned by your query then by a simple loop you can populate your array......

    I dont know about your data and array structure...So here is a snippet of code which can be useful.......

    Code:
     
    Dim myArray(m,n) as String 
    For i as Integer=0 To m
    For j as Integer=0 To n
    	 myArray(m,n)=mydataset.Table(0).Row(m).Item(n)
    Next
    Next

    Comment

    Working...