Do I need an adapter/connection to run an SQL statement?
-
Hi, I'm using VB.NET 2005 Express, and I'm working with an XML file, which populates a DataSet, DataTable and DataGridView. An amazing achievement for somebody of my current skill set!! The way my app works at the moment, there is a possibility that I could end up with duplicate entries in my XML file, so I was thinking of running an SQL statement to remove any duplicates. Everything I've found so far seems to suggest that I need to use an adapter and a connection in order to be able to run an SQL statement. OK - but this doesn't seem right to me. If it IS correct, it seems that I'd have to create the adapter and a connection AFTER I've read in all my data (ReadXML) - which seems odd. Perhaps I'm just over-complicating my problem??? Any advice would be really appreciated.
-
Hi, I'm using VB.NET 2005 Express, and I'm working with an XML file, which populates a DataSet, DataTable and DataGridView. An amazing achievement for somebody of my current skill set!! The way my app works at the moment, there is a possibility that I could end up with duplicate entries in my XML file, so I was thinking of running an SQL statement to remove any duplicates. Everything I've found so far seems to suggest that I need to use an adapter and a connection in order to be able to run an SQL statement. OK - but this doesn't seem right to me. If it IS correct, it seems that I'd have to create the adapter and a connection AFTER I've read in all my data (ReadXML) - which seems odd. Perhaps I'm just over-complicating my problem??? Any advice would be really appreciated.
It sounds to me like you're over complicating the problem. You'd do better to just check for a node before you add it, don't add it if it exists. Solve the underlying problem instead of trying to fix it later.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
It sounds to me like you're over complicating the problem. You'd do better to just check for a node before you add it, don't add it if it exists. Solve the underlying problem instead of trying to fix it later.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Thanks for your reply. Your advice is good. My project is an Exchange Rate application which is importing 200 rows of data from a Word document. At the moment, I'm just reading it in from Word, reading in my XML file, adding the new rows to the existing table, and writing my XML file containing everything. With your suggestion, am I right in thinking that I'd need to sort my DataTable so that when I come to add my new row, I've got all my countries sorted so that they're together, and it only has to work with a few rows to determine if the data already exists? Meanwhile, I'd still like to know (for future reference) whether I need an adapter/connection to run SQL statements.
-
Thanks for your reply. Your advice is good. My project is an Exchange Rate application which is importing 200 rows of data from a Word document. At the moment, I'm just reading it in from Word, reading in my XML file, adding the new rows to the existing table, and writing my XML file containing everything. With your suggestion, am I right in thinking that I'd need to sort my DataTable so that when I come to add my new row, I've got all my countries sorted so that they're together, and it only has to work with a few rows to determine if the data already exists? Meanwhile, I'd still like to know (for future reference) whether I need an adapter/connection to run SQL statements.
If you have XML, you can use SelectSingleNode on an Xmldocument to see if you r node existss.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )