You have to do dotnet.loadassembly “System.Data” first. I have some code at work that may be of use to you.
And by the way… does anyone knows why the listbox doesnt display any info in a dataset?
I’ve sucessefully created a dataset, a table adapter, I can access the values on the rows, but after assigning the Datasource and Displaymember, the listbox remains empty… cant figure that out.
I dont have Max 9 here so I’ll write what I can remember It’s something like this
rollout rollmain "dotnet"
dotnetcontrol lst_test "System.Windows.Forms.Listbox" width:290 height:290 align:#center
on rolmain open do
constring="data source=.\SQLEXPRESS;Initial Catalog=YOUR_DATABASE_HERE;Integrated Security=True;Connect Timeout=30"
con=dotnetobject "System.Data.SqlClient.SqlConnection" constring
tableadapter=dotnetobject "System.Data.SqlClient.SqlDataAdapter" "SELECT * FROM tasks" constring
tableadapter.Fill dataset "tasks"
--At this point you have your data into the dataset created before
--Now the problem seems to be with the listbox databinding... cant understand why
lst_test.DisplayMember="taskname" --This is the column name used for displaying data and I thing the problem is here somewhere...
lst_test.ValueMember="id_task" -- Primary key column
--if you want to confirm the data in your dataset you could do this loop. This shows that the problem is not getting the data into the dataset but displaying it in the listbox
for i=0 to dataset.tables["tasks"].rows.count do -- it's this or dataset.tables["tasks"].rows.items.count, can't quite remember
print dataset.tables["tasks"].rows.item[i].item["taskname"] --I'm not sure about this one, but a ShowProperties on dataset.tables["tasks"] should help a little
createdialog rollmain 300 300
And that’s about it, hope this helps and if someone knows why the listbox is not displaying my data please say something! Cyas!