Happy New Year AlanC!
Thanks for your suggestion to switch C# and I will take it seriously. 😀. As for the datatable property, I tried to use that but seems not available in VB.NET, only tolist or to array could be accessable within datasets, is DataTable specifically designed for C# only?
Regards,
Stanley
You need to translate my C# to VB.NET: I can't easily do that. Look at a tool like this one: Code Converter C# to VB and VB to C# – Telerik
Here is the what I believe is the correct code for VB.NET:
For Each xpt In xptLib.DataSets(0).Tables(0);
Yes, I did convert it to VB format but says datatable or table is not a member of datasets.
And this is VB.NET, not VB? Can you show code?
Yes, used in VB.NET. Below is the code, I tried to use Tables, DataTables, Tables(0), DataTables(0) but neither works, saying Tables.DataTables not the member of DataSets. I just would like to think about a more efficient way to import the data and bind with a datagridview, the codes in the second part works but might not be the best way. Please advise. Thanks a lot~~
Regards,
Stanley
Stanley,
The issue was on my side. I saw the word 'DataSets' and assumed it was .NET: it wasn't. Just a **** move on my part. I have updated the Git repository with a new build. Highlights:
New ToDataSet method
Let me know of any issues. Thanks for your patience and testing.
PS - When you post to these coding forums, never use an image. In this case I didn't need the code but normally someone has to highlight the code and copy and an image does not work.
That's great, just test it and works well, except one minor issue when imported cell with null value, I just added the if statement as follows and works well now.
foreach (var obs in xds.Observations)
{
var dr = dt.Rows.Add();
foreach (var c in obs.Cells)
{
if (!(c.Value is null))
{
dr[c.Column] = c.Value;
}
}
}
Cheers,
Stanley
Another issue just found was that the returned table name was always 9.4, not the real file name.
Thanks Stanley. Fixed both issues and pushed to repo.
Also, changed your if to the following (is not null is a new feature in C#9. Resharper will bark but is legit):
if (c.Value is not null) { dr[c.Column] = c.Value; }
I did a complete overhaul on the way that the library works for exporting content. Minor impact on the initialization (but breaking change). I wrote this code years ago so it was pretty different mindset and built as a console app. Changed it up to reflect a library. See readme on the repo for sample code.
Hi Alan,
Trying to use your SaviTransport package. I am not getting any Datasets back (it is zero). I doubt if the transport file I got is a compressed version. Any help and guidance from you is much appreciated.
Thanks
Nivasoft
What version of XP file is it? Is the extension xpt? Any chance you can share it in private? If so, send me an email directly with your email address and i will provide a private folder for you to use.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.