Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Do I need an adapter/connection to run an SQL statement?

Do I need an adapter/connection to run an SQL statement?

Scheduled Pinned Locked Moved Visual Basic
csharpdatabasexmlhelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    penguin5000
    wrote on last edited by
    #1

    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.

    C 1 Reply Last reply
    0
    • P penguin5000

      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.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      P 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        P Offline
        P Offline
        penguin5000
        wrote on last edited by
        #3

        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.

        C 1 Reply Last reply
        0
        • P penguin5000

          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.

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          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 )

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups