You need to call the Add method of your Rows collection to actually add the DataRow to your DataTable. Here is some sample code:
Dim dr As DataRow
Dim fi As FileInfo
Dim dir As New DirectoryInfo("C:\")
Dim dt As New DataTable()
dt.Columns.Add("FileName", GetType(System.String))
dt.Columns.Add("Size", GetType(System.Int32))
For Each fi In dir.GetFiles()
dr = dt.NewRow()
dr(0) = fi.Name
dr(1) = fi.Length
dt.Rows.Add(dr)
Next
>Update, I created a empty dataset modifying the sql statement to return an empty table perform the Addnew() command work fine. Try to assign the new value for the column and receive the error there no row 0, Excecute the count comand and return 1 so what is wrong?
>
>the line used was
>'xtext any text box in the form that i dont remember the name now.
>objsocio_economica.table("socio_Economica).row(0)("num_control") = xtext.tostring()
>also I try to replace the 0 with 1 and get the same result. The dataset is bound to a grid and the grid is showing the new row when I execute the addnew() command.
-----------------------------------------
Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.comwww.prenia.comWeblog: blogs.prenia.com/cathi