#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11

    How can I REmove an Item in a DataBase ? (different way?)


    Hi everybody.

    I would like to know wich way I can use to delete a row in a database ?

    My problem is that I have some items that need to be removed.
    I know I can use a database like doing
    Code:
    frmItems.BindingContext(frmItems.DataSetAdresse1, "Adresse").RemoveAt(iIndex)
    but using a database that need to read all the lines in it and remove the one not necessary is stupid and it's take way too much time for the program. And I also got a bug when I remove 2 or + items and that I try to access to the next item in the table.

    What I was thinking of using is a OleDbCommand and OleDbReader with a query that will only search the objects that I need in SQL. and then compare them and delete the ones I don't need.

    but if I use a OleDb, how do I remove the items I don't want ? is there a command for that ?

    or is my only possibility the DataSet and DataRow ? or is there other way to do it ? other method or something ? if you know any others that might help me. please tell me ! every opinion and idea is welcome.

    I got an headache just for thinking about how I could solve all those problems.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11
    would it be something like that ?

    OleDBCommand.CommandText = "Delete MyTable where MyNumero = " + MyVariable + ";"

    OleDBCommand.ExecuteReader

    loop


    ???? would there be other way then this and is that the correct way to do it and correct syntax ?
    Last edited by Watever; September 24th, 2003 at 01:55 PM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11
    I still haven't found my problem !

    what I am doing

    Code:
    OleDBCommand.CommandText = "Delete adresse where (norue = '" + _
                                                    OleDataR.Item("norue") + "') and (noreleve = " + _
                                                    "(select noreleve from releve where codeprojet = '" + _
                                                    NoReleve + "'))"
    OleDBCommand.ExecuteNonQuery()
    it's not working, it's keep telling me
    " NoRue = Invalide double type "

    what the hell ?
    I have done some test with select etc... and it's working but this one isn't working !


    but the worst part is that the bug don't happen when I Excute but when I do the CommandText of the OleDBCommand
    damn it ! just crazy today
    Last edited by Watever; September 29th, 2003 at 09:23 AM.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11
    forget about it ! I found it !

    but remember that + is not a &

    and in a string use "&"
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Montreal, Canada
    Posts
    486
    Rep Power
    11
    Guys please help me ! I need to solve that problem has fast has I can !

    I still have a lot of test to do and I have a final date in 2 days. I don't know how I will do that !

IMN logo majestic logo threadwatch logo seochat tools logo