0

how do i delete all the data which is stored in the sql table????
i want to delete only the data present in one table without dropping the table when i click on the command button in vb6 plz help :(:(:(:( its really urgent

5
Contributors
7
Replies
12
Views
5 Years
Discussion Span
Last Post by jireh
0

How you connect to database ?

If using ADO then try this

conn.begintrans  'conn-----adodb connection object
conn.execute "delete from table_name"
conn.committtrans

Edited by debasisdas: n/a

0

"Recordset.Delete" will only delete the active row. You either have to iterate through the recordset and advance the current row or do what @debasisdas says. Please don't post if you haven't tested your solution.

Edited by BitBlt: n/a

0

well, it works fine in my project..and something similar. selecting a multiple data in list table and click a command button will delete all the data in my table.

0

Noted. It didn't work in the test I did, so please share your scenario that DID work. We're all about learning here, I'm curious to see your complete solution.

I tested with VB6 using an ADODC control connected to a SQL2008 backend. If convenient, please post important details, including database engine, connection string (except passwords, of course :D), surrounding control types, and so on. Personally, I'm interested in solving the problem for the OP. If I can learn something along the way, that's a bonus.

0
set conn=Server.CreateObject("ADODB.Connection")
  conn.Provider="Microsoft.Jet.OLEDB.4.0"
  conn.Open "c:/mydata/northwind.mdb"

  sql = "DELETE FROM customers"
  sq l= sql & " WHERE customerID='" & cid & "'"
  
  on error resume next
  
  conn.Execute sql

  if err<>0 then
    MsgBox.Show "No update permissions!"
  else
    MsgBox.Show "Record " & cid & " was deleted!"
  end if

Hope That Helps...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.