Question How do I populate an array while creating a datatable? Breaking it up instead of fill

tgf-47

Member
Joined
Feb 16, 2010
Messages
15
Programming Experience
Beginner
I want to modify this function to populate an array with each item in the database.

I have tried various options, but I just can't get it to work


Private Function ConnectMe() As DataTable
Dim conn As String = "Server=192.168.0.36;Port=3306;Database=wswc;Uid=root;Pwd=Jack"
Dim cmd As String = "SELECT * FROM st_users"
Dim ad As New MySql.Data.MySqlClient.MySqlDataAdapter(cmd, conn)
Dim topics As New DataSet()
ad.Fill(topics)
ConnectMe = topics.Tables(0)
End Function

Instsead of fill, I want to one by one add it to the dataset and also an array
 
If you want the data in the DataSet anyway then why not just stick with the code you've got to do that? Once the DataTable is populated you can simply loop through it and populate the array.
 

Latest posts

Back
Top