Fill an array from a table field problem

jotae

Member
Joined
Jan 8, 2008
Messages
5
Programming Experience
1-3
Hi! I have this code for my DB and I'm using Visual Basic 2010 Express

VB.NET:
Dim dta As OleDbDataAdapter
Dim con As New OleDbConnection

.....more code...

Me.con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & "c:\socios.mdb; Persist Security Info=False"
         con.Open()
       dta = New OleDbDataAdapter("Select nombre from inscritos where status= 1 ", con)
         Dim oCB As OleDbCommandBuilder = New OleDbCommandBuilder(dta)
        dst = New DataSet
        dta.Fill(dst, "inscritos")
        vActivos = Me.dst.Tables("inscritos").Rows.Count

I need filling an array with the field NOMBRE. I think the better way is a Datareader but I don't know how. Can help me, please? Thx.
 
hope the below code helps.

Dim dtDataTable As DataTable = dst.Tables("inscritos")
Dim numberArray(dtDataTable.Rows.Count) As Integer

For count = 0 To dtDataTable.Rows.Count - 1
Dim dtrow As DataRow = dtDataTable.Rows(count)

numberArray(count) = dtrow("nombre")
Next
 
Thx. Working but I receive a error in this line:

numberArray(counter) = dtrow("nombre")

The error:

La conversión de la cadena "ROBERTO ANTONIO VALLARINO COLL" en el tipo 'Integer' no es válida.

My Visual is in spanish but the error is "Conversion string "....." to type integer is not valid.

Really, thx for you answer.
 
Back
Top