saving table data

Discussion in 'Questions (Windows Mobile)' started by Smee, Sep 26, 2009.

  1. Smee

    Smee Well-Known Member Licensed User

    is there a way to save a table to a database faster than this. once the records start to add up this method becomes very slow


    For i = 0 To sTblOrders.RowCount-1
    Timex=sTblOrders.Cell("OrderTime",i)
    ProdNo=sTblOrders.Cell("ProductCode",i)
    ProdPrice=sTblOrders.Cell("ProductPrice",i)
    Qty=sTblOrders.Cell("Qty",i)
    'add row to database
    ItemNo =i
    txt= "('" & VanNo & "','" & CustCode & "','" & TrxNo & "','" & ItemNo _
    & "','" & Timex & "','" & ProdNo & "','" & ProdPrice & "','" & Qty & "')"
    command.CommandText = "INSERT INTO Sales VALUES " & txt
    Command.ExecuteNonQuery
    Next

    Still Learning
    :sign0104:
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Yes. First you can use Connection.StartTransaction and Connection.EndTransaction before and after the loop to increase the performance.
    However a simpler solution is to use Connection.CreateSQLTable.
     
  3. Smee

    Smee Well-Known Member Licensed User

    Thank you Erel,

    However Connection.CreateSQLTable. would not work because the Table already exists and the data is an update of an existing table. Is there an append command similar to this?

    Thanks

    Joe
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You can use CreateSQLTable to create a temporary table.
    Then issue a command like:
    Code:
    INSERT INTO Sales SELECT * from TemporaryTable
     
  5. Smee

    Smee Well-Known Member Licensed User

    Thank you Erel

    i will try this
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice