(FYI, using VB .NET 2003)
Can someone help me with this... I'm trying to read in an XML file... it
appears to work in that the DataSet ReadXML method dose not fail and then I
am able to access the table names that are in the XML file, but I'm not able
to access the rows.
Here's the code that I've got - it assumes that the fileName passed in
already exists:
Public Sub GetInput(ByVal fileName As String)
dsFileCopy = New DataSet("fileCo py")
Dim dtActions As DataTable = New DataTable("acti on")
Dim dtIni As DataTable = New DataTable("ini" )
dtIni.Columns.A dd("title", Type.GetType("S ystem.String"))
dtIni.Columns.A dd("information ", Type.GetType("S ystem.Boolean") )
dtActions.Colum ns.Add("source" , Type.GetType("S ystem.String"))
dtActions.Colum ns.Add("target" , Type.GetType("S ystem.Boolean") )
dtActions.Colum ns.Add("type", Type.GetType("S ystem.Boolean") )
dsFileCopy.Tabl es.Add(dtIni)
dsFileCopy.Tabl es.Add(dtAction s)
Try
dsFileCopy.Read Xml(fileName)
Catch ex As Exception
'if the file is blank or not in XML format we will fall here
Trace.WriteLine ("Invalid status file " & fileName)
MsgBox(ex.ToStr ing, MsgBoxStyle.Exc lamation, "NSDUH FileCopy")
Application.Exi t()
End Try
End Sub
The above code works fine, but I get a run-time error when I execute the
following statement:
Debug.WriteLine (dtIni.Rows(0). Item("informati on"))
The error says there is no row(0) in the table... So maybe I'm accessing the
elements of the table wrong. What I want todo is loop through each row and
perform each action based on the specifications. .. Am I accessing the DataSet
element correctly?
So, I tried printing all the elements in the DataSet using this code:
Private Sub PrintDataSet(By Val dsActions As DataSet)
For Each t As DataTable In dsActions.Table s
Console.WriteLi ne("TableName: " + t.TableName)
For Each r As DataRow In t.Rows
For Each c As DataColumn In t.Columns
Console.Write(C ontrolChars.Tab + " " + r(c).ToString() )
Next c
Console.WriteLi ne()
Next r
Next t
End Sub
But all that prints to the console is the names of the tables...
Here's the XML file:
<?xml version="1.0" standalone="yes " ?>
<fileCopy xmlns="http://tempuri.org/FileCopyInput.x sd">
<ini>
<title>Some Title here</title>
<information>Ot her info here</information>
</ini>
<action>
<source>.\fileA </source>
<target>C:\dest inationA</target>
<type>copy</type>
</action>
<action>
<source>.\fileA </source>
<target>C:\dest inationA</target>
<type>move</type>
</action>
<action>
<source>.\fileA </source>
<target>C:\dest inationA</target>
<type>delete</type>
</action>
</fileCopy>
Any input would be greatly appreciated.
Charles 1 2185
I don't know the details but it looks like the contents of the xml file I was
reading in was causing the problem... maybe someone out there can provide a
through explination as to what the situation is.
Here's how my "FileCopyInput. xml" originally began:
<?xml version="1.0" standalone="yes " ?>
<fileCopy xmlns="http://tempuri.org/FileCopyInput.x sd">
:
:
When I removed (commented out) the "xmlns" attribute from the FileCopy node,
everthing worked just fine. So here's how the file looks now:
<?xml version="1.0" standalone="yes " ?>
<!--<fileCopy xmlns="http://tempuri.org/FileCopyInput.x sd">-->
<fileCopy>
Obviously I played around with defining my own xml schema and it got inseted
into the XML file I was defining. How would I change the xmlns attribute to
point to the XML schema that I defined? can I use a file:/// URL? Or specify
local host?
I'd appreciate any feedback and/or links for reading!
THanks,
Charles
"hz****@nopost. com" wrote: (FYI, using VB .NET 2003) Can someone help me with this... I'm trying to read in an XML file... it appears to work in that the DataSet ReadXML method dose not fail and then I am able to access the table names that are in the XML file, but I'm not able to access the rows. Here's the code that I've got - it assumes that the fileName passed in already exists:
Public Sub GetInput(ByVal fileName As String) dsFileCopy = New DataSet("fileCo py") Dim dtActions As DataTable = New DataTable("acti on") Dim dtIni As DataTable = New DataTable("ini" ) dtIni.Columns.A dd("title", Type.GetType("S ystem.String")) dtIni.Columns.A dd("information ", Type.GetType("S ystem.Boolean") ) dtActions.Colum ns.Add("source" , Type.GetType("S ystem.String")) dtActions.Colum ns.Add("target" , Type.GetType("S ystem.Boolean") ) dtActions.Colum ns.Add("type", Type.GetType("S ystem.Boolean") ) dsFileCopy.Tabl es.Add(dtIni) dsFileCopy.Tabl es.Add(dtAction s) Try dsFileCopy.Read Xml(fileName) Catch ex As Exception 'if the file is blank or not in XML format we will fall here Trace.WriteLine ("Invalid status file " & fileName) MsgBox(ex.ToStr ing, MsgBoxStyle.Exc lamation, "NSDUH FileCopy") Application.Exi t() End Try End Sub
The above code works fine, but I get a run-time error when I execute the following statement: Debug.WriteLine (dtIni.Rows(0). Item("informati on")) The error says there is no row(0) in the table... So maybe I'm accessing the elements of the table wrong. What I want todo is loop through each row and perform each action based on the specifications. .. Am I accessing the DataSet element correctly?
So, I tried printing all the elements in the DataSet using this code: Private Sub PrintDataSet(By Val dsActions As DataSet) For Each t As DataTable In dsActions.Table s Console.WriteLi ne("TableName: " + t.TableName) For Each r As DataRow In t.Rows For Each c As DataColumn In t.Columns Console.Write(C ontrolChars.Tab + " " + r(c).ToString() ) Next c Console.WriteLi ne() Next r Next t End Sub But all that prints to the console is the names of the tables...
Here's the XML file: <?xml version="1.0" standalone="yes " ?> <fileCopy xmlns="http://tempuri.org/FileCopyInput.x sd"> <ini> <title>Some Title here</title> <information>Ot her info here</information> </ini> <action> <source>.\fileA </source> <target>C:\dest inationA</target> <type>copy</type> </action> <action> <source>.\fileA </source> <target>C:\dest inationA</target> <type>move</type> </action> <action> <source>.\fileA </source> <target>C:\dest inationA</target> <type>delete</type> </action> </fileCopy>
Any input would be greatly appreciated.
Charles This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bob |
last post by:
Everybody,
I've been doing a lot of on-line research and cannot find
any reference to the exact problem I'm having.
Let me preface this question with the fact that I'm coming
from an Oracle background so my approach may not be the best
way to tackle this. However, from the research I have done
this approach seems reasonable. Also, I know about the
undocumented procedure sp_MSforeachtable. That can give me a
|
by: Deepa |
last post by:
Hi
I have a DataSet file (xml) which I need to convert it into a tab delimited
file. I need to write a C# console application for doing the same. Can anyone
help me out with the code to do it? I'd appreciate any kind of help.
Thanks
|
by: Bill C. |
last post by:
Hi,
I've got a simple console app that just reads an XML file into a DataSet
then prints out a description of each table in the DataSet, including
column names and row values for each column. I'm getting some strange
results depending the input XML file I use. I was wondering if somebody
could help me understand what is going on or point me to a good reference.
The code for my program looks like this:
|
by: Carl Lindmark |
last post by:
*Cross-posting from microsoft.public.dotnet.languages.csharp, since I
believe the question is better suited in this XML group*
Hello all,
I'm having some problems understanding all the ins and outs with datasets
and datatables (and navigating through the filled datatable)...
Just when I thought I had gotten the hang of it, another problem arose:
I can't seem to access the "xsi:type" attribute. That is, the XML file looks
|
by: ALI-R |
last post by:
Hi All;
I'm reading the following xml file into a Dataset but there are only 4
datatables in my dataset (which should be 5)
Is that because I have two nodes with the same name (detail) in my xml file?
how can I fix this?
Thanks for your time.
<?xml version="1.0" ?>
| |
by: Mr. B |
last post by:
VB.net 2003 c/w Framework 1.1 and MS Access db
We have a commercial program that does our Acounting and Time Sheets
(Timberline). At least once a day our Accounting department runs a Script
file that Exports info into an MS Access db file and which has 7 Tables (stuff
like Project info, Project numbers, User names, etc).
I wrote a Time Sheet entry application to read this info and to allow
Employees to write their Time Sheet data into...
|
by: c.w.browne |
last post by:
Hi,
Ive had a bit of a look around for other people with this problem and
cant find anything that solves it in my case, so I'm afraid im going to
have to bother you all with a post of my own.
Essentially, I am trying to read in an xml schema and then an xml
document into a dataset using ReadXmlSchema and then ReadXml. When i do
this, i end up with a table in the dataset (which i assume is created
when i read the schema), but no rows...
|
by: rwiegel |
last post by:
I'm trying to read rows from an Excel file and display them in an
ASP.NET DataGridview. I am using C# for the code file. I am using
OleDb to read from the Excel file. The columns that contain text load
into the grid fine, but the columns that contain just numbers don't
show up at all. I tried converting the text of the cells to an
integer first, but I get an error for converting from a type DBNull.
Anybody who has any help at all, I...
|
by: DennisBetten |
last post by:
First of all, I need to give some credit to Mahesh Chand for providing me with an excellent basis to export data to excel.
What does this code do:
As the title says, this code is capable of extracting all tables and it's data from any given database! I was searching the net for a program like this, but I didn't come accross any (free) versions. So I decided to write it myself.
To get this code to work, you need to add a reference to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |