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

Recommended Answers

All 7 Replies

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

i have connected using adodc

ADODC1.Recordset.Delete

"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.

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.

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.

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.