Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deelting records in a dB

Status
Not open for further replies.

capone67

Programmer
Nov 6, 2000
115
CA
Hi Gang

I am tryin gto delete records from an access database but I continue to get error 3001 invalid argument. Here is the code i am trying to use and MySQL is "Delete * from Schedule where hour=0;". I am kinda doing a hit and miss approach here since the MS documentation is, well MS docuemntation. Why is this stuff so easy in ASP and so difficult in VB? Also, how can I specify that the database to be used is located on a server instead of locally? I am trying to do this project as an ActiveX control. When I try to run the page from other locations I get an ISAM error or no error at all and just a red x on the screen. I haven't put in any safe for scripting or safe for ???? code in my active X control.

Hope I don't sound too inept here.

TIA

Ken Patenaude

Private Sub DeleteRecordsetX(MySQL)



Dim dbsNorthwind As Database
Dim rstEmployees As Recordset
Dim lngID As Long

Set dbsNorthwind = OpenDatabase("C:\videoworx\videoworx.mdb")
Set GridData = dbsNorthwind.OpenRecordset( _
MySQL, dbOpenDynamic)


' Delete the employee record with the specified ID
' number.

With GridData
.Seek "=", "*"
If .NoMatch Then
Else
.Delete
End If
End With


rstEmployees.Close
dbsNorthwind.Close



End Sub
 
to connect to a remote database on a server you can use the ADODB object. to use this you have to add the Microsoft Activex Data object to the references. for the connection you can specify a connection string to connect to any remote database using approproate JET/ODBC driver.

as for the error you are getting, with ADO you can directly execute the delete SQL and dont have to do any further processing.
btw in your present code at which line does the error occur?
 
I am getting the error at this line in the code.

Set GridData = dbsNorthwind.OpenRecordset( _
MySQL, dbOpenDynamic)

Ken
 
you can either change the SQL to "select * from ..." and then open the recordset and execute the delete method of the recordset object or you can directly use dbsNorthwind.execute MySQL check the appropriate syntax. it will delete all the required records from the database unless you face some locking or other issues.

regards,
manish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top