sri ranjani

sri ranjani

  • NA
  • 81
  • 3.6k

Need to fetch value from table and store it in a array

Oct 16 2018 11:14 PM
Hi,
I need to select values from table and i need to store it in a array.
 
Protected Sub getwmslocationlist(ByVal site As String) ', ByVal s As String)
Dim oProducts As List(Of String)
Dim aProducts As String()
Dim i As Integer
Using con As SqlConnection = New SqlConnection(constr)
Using cmd As SqlCommand = New SqlCommand("select * from InventLocation iloc,wmsLocation wmsloc where iloc.dataareaid='BRM' and wmsloc.dataareaid='BRM' and iloc.InventSiteId='" & site & "' and iloc.InventLocationType=1 and wmsloc.inventLocationId=iloc.InventLocationId")
Dim dt As SqlDataAdapter = New SqlDataAdapter()
Try
cmd.Connection = con
con.Open()
dt.SelectCommand = cmd
Dim dTable As DataTable = New DataTable()
dt.Fill(dTable)
oProducts = New List(Of String)
For i = 0 To dTable.Rows.Count - 1
oProducts.Add(dTable.Rows(i)("wmslocationid"))
Next
aProducts = oProducts.ToArray
Catch ex As Exception
LblError.Text = Err.Description
If con.State = ConnectionState.Open Then
con.Close()
End If
End Try
End Using
End Using
End Sub
 how could i do that?
 

Answers (1)