Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBS Script Delete SQL Record

926 views
Skip to first unread message

Joshua C. Clark

unread,
Apr 11, 2003, 4:12:35 PM4/11/03
to
Any way to delete a record, I can add, update, just not able to delete
records..


Ray at work

unread,
Apr 11, 2003, 4:30:33 PM4/11/03
to
What does "can't" mean? Error?

"DELETE FROM [TableName] WHERE [Field]='value';"

Ray at work

"Joshua C. Clark" <Jo...@Network-Medics.Com> wrote in message
news:#fAM7aGA...@TK2MSFTNGP10.phx.gbl...

Joshua C. Clark

unread,
Apr 11, 2003, 4:37:42 PM4/11/03
to
What about if want to delete Multiple Rows?


"Ray at work" <r...@work.spam> wrote in message
news:eV#LwkGAD...@TK2MSFTNGP11.phx.gbl...

Joshua C. Clark

unread,
Apr 11, 2003, 4:37:20 PM4/11/03
to
Just did not know the syntax, thanks!!


"Ray at work" <r...@work.spam> wrote in message
news:eV#LwkGAD...@TK2MSFTNGP11.phx.gbl...

Ray at work

unread,
Apr 11, 2003, 4:46:14 PM4/11/03
to
That's where your WHERE clause comes in. You identify which rows you want
to delete by using a WHERE clause.

Ray at work

"Joshua C. Clark" <Jo...@Network-Medics.Com> wrote in message

news:uZJJ9oG...@TK2MSFTNGP11.phx.gbl...

Ray at work

unread,
Apr 11, 2003, 5:33:49 PM4/11/03
to
1. Posting attachments will get you scolded by many. :]

2. Don't do "DELETE * FROM" It's just "DELETE FROM" When you delete, the
entire row is deleted, so you do not have to (/cannot) specify which columns
to delete.

If you execute "DELETE FROM TABLE" it will clear out the whole table, btw.

Ray at work

"Joshua C. Clark" <Jo...@Network-Medics.Com> wrote in message

news:OZNBR9GA...@TK2MSFTNGP12.phx.gbl...
> I have a SQL DB called eventlog, I have a table called table, my ODBC is
> correct, and I am using this Script, what am I missing,
>
> Const adOpenStatic = 3
> Const adLockOptimistic = 3
> Const adUseClient = 3
> Set objConnection = CreateObject("ADODB.Connection")
> Set objRecordset = CreateObject("ADODB.Recordset")
> objConnection.Open "DSN=eventlogs;"
> objRecordset.CursorLocation = adUseClient
> objRecordset.Open "Delete * FROM table" , objConnection, adOpenStatic,
> adLockOptimistic
> objConnection.Close


>
> "Ray at work" <r...@work.spam> wrote in message

> news:eH7ShtGA...@TK2MSFTNGP12.phx.gbl...

Ray at work

unread,
Apr 11, 2003, 5:40:12 PM4/11/03
to
Oh, and you don't need to create a recordset. Just do objConnection.Execute
"DELETE FROM TABLE"

Ray at work

"Ray at work" <r...@work.spam> wrote in message

news:ujvQHIHA...@TK2MSFTNGP11.phx.gbl...

Joshua C. Clark

unread,
Apr 11, 2003, 6:34:18 PM4/11/03
to
Something like this, I cannot get it working though..

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")

objConnection.Open "DSN=eventlogs;"
objConnection.Execute DELETE FROM TABLE "TABLE"
objConnection.Close


"Ray at work" <r...@work.spam> wrote in message

news:#3kcqLHA...@TK2MSFTNGP11.phx.gbl...

Ray at work

unread,
Apr 11, 2003, 6:42:24 PM4/11/03
to
It's not "delete from table table"

DELETE FROM THENAMEOFYOURTABLEFROMWHICHYOUWOULDLIKETODELETERECORDS

Ray at work

"Joshua C. Clark" <Jo...@Network-Medics.Com> wrote in message

news:ODcrHqHA...@TK2MSFTNGP11.phx.gbl...

Joshua C. Clark

unread,
Apr 11, 2003, 6:48:36 PM4/11/03
to
I got it stupid me, thanks!!!!!

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=eventlogs;"
objRecordset.CursorLocation = adUseClient

objRecordset.Open "Delete FROM event" , objConnection, _


adOpenStatic, adLockOptimistic
objConnection.Close
"Ray at work" <r...@work.spam> wrote in message

news:Os2YbuHA...@TK2MSFTNGP10.phx.gbl...

Ray at home

unread,
Apr 12, 2003, 3:51:10 AM4/12/03
to
Nice, although there is still no need to create a recordset.


Set objConnection = CreateObject("ADODB.Connection")

With objConnection
.Open "DSN=eventlogs;"
.Execute "DELETE FROM EVENT"
.Close
End With
Set objConnection = Nothing

Ray at home


"Joshua C. Clark" <Jo...@Network-Medics.Com> wrote in message

news:eQtsGyHA...@TK2MSFTNGP12.phx.gbl...

Paul White

unread,
Apr 12, 2003, 5:12:37 AM4/12/03
to

"Ray at home" <r...@ajf8jalskdfna.sefrhja7yasdf.com> wrote in message
news:#x9cwcMA...@TK2MSFTNGP12.phx.gbl...

> Nice, although there is still no need to create a recordset.
> Set objConnection = CreateObject("ADODB.Connection")
> With objConnection
> .Open "DSN=eventlogs;"
> .Execute "DELETE FROM EVENT"
> .Close
> End With
> Set objConnection = Nothing


That will still delete all records in the table. Remember to use your WHERE
clause.

DELETE FROM EVENT WHERE EVENT_DATE < Date() - 30

Ray at home

unread,
Apr 13, 2003, 1:26:13 AM4/13/03
to
He's been warned more than once about that. :]

Ray at home

"Paul White" <p...@bigpond.net.auNOSPAM> wrote in message
news:9MQla.940$hF....@news-server.bigpond.net.au...

Joshua C. Clark

unread,
Apr 14, 2003, 8:30:45 AM4/14/03
to
Thank you all for your help, actually I do want to delete everything in my
Table, what I created was, for all of my servers I have every 30 seconds the
Event logs exported, then SQL imports them every minute, but since I want
them to be always current I needed to delete everything in the Table instead
of using an Update, then I use an ASP page I created to display them which
is refreshed every minute, so that way when I or a collegue is paged instead
of wasting time VPN'ing into our WAN we can simply open our browser and see
all of the event logs.


"Ray at home" <r...@ajf8jalskdfna.sefrhja7yasdf.com> wrote in message

news:O3H3WwXA...@TK2MSFTNGP11.phx.gbl...

0 new messages