delete all post in db RRS feed

  • Question

  • Hi I use this code to put data from xml to Sql db - tabel order
    Module Module1
    	Sub Main()
    		Dim _db As New integrationDataContext
    		Dim _orderfile As XDocument = XDocument.Load("c:\xml\orders.xml")
    		Dim _orders = _orderfile.<orders>.<order>
    		For Each _order In _orders
          Dim _o As New order
    			_o.OrderNumber = _order.@number
    			_o.pickup = _order.<pickup>.Value
    			_o.deliver = _order.<deliver>.Value
    			_o.deliverdate = Date.Parse(_order.<deliverdate>.Value)
        _db = Nothing
        _orderfile = Nothing
        _orders = Nothing
    	End Sub
    End Module

    What i want is delete all post in tabel order before i put the new data in from Xml file
    I can do' by ADO but maybe there is a better/smarter Way ?


    Wednesday, August 11, 2010 6:00 AM


All replies

  • Alvin,

    Some questions:

    What is "all post"?

    Why are you setting objects to nothing which simply go out of scope (even if they did not does nothing nothing)

    However, probably are you looking for one of the remove methods.

    You can make a chose of them in the beneath link 


    Wednesday, August 11, 2010 6:58 AM
  • Sorry bad writing

    What i want is to delete all records in the table order.




    Wednesday, August 11, 2010 7:08 AM
  • Do you want to delete all records in the Orders table first?

    Does the _db.orders object have some methods that you can use.

    Maybe this article can give you some examples http://msdn.microsoft.com/en-us/library/bb425822.aspx#linqtosql_topic9 (search for delete or Remove)

    Best regards Arild Røksund, Norwegian developer (SQL & .net), Omega AS (please Vote as helpful if helpful)
    • Marked as answer by Alvin Kuiper Wednesday, August 11, 2010 9:54 AM
    Wednesday, August 11, 2010 7:10 AM