borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2011 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Next Topic (i have one question ?) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Execute dont work with vb6 and access 2000, why?
Poster Message
LEKO
Level: Trainee

Registered: 22-02-2010
Posts: 2

icon Execute dont work with vb6 and access 2000, why?

Hi all, im accessing access 2000 with dao 3.6 and vb 6.0 sp4, im not using data control, and i dont want to use it.

I open the database with...

Set ws_PDF = DBEngine.Workspaces(0)
Set BASE_PDF = ws_PDF.OpenDatabase(RUTA_PDF)


Base open perfectly and can use select sql to read without problems, the problems are when i use insert, delete or update, the execute command do nothing.

Something like...

sql = "DELETE FROM PERSONAS WHERE codigopersona=" & codigoRP & " and CodigoC=1 and NumeroC=1 and CodigoD=1"

BASE_PDF.Execute sql


Execute, no error, but nothing happens, if i open the database in access, open the table, and access to the table, vb6 report the problem is locked (with select), when use execute (insert, delete etc), nothing happens.

I really need help with that, i cant find a solution.

Help me please.

22-02-2010 at 07:08 AM
View Profile Send Email to User Show All Posts | Quote Reply
Anaru
Level: Trainee

Registered: 22-02-2010
Posts: 1
icon Re: Execute dont work with vb6 and access 2000, why?

Hello LEKO,

My knowledge of Visual Basic 6.0 may be somewhat limited where the usage of DAO and MS Access is conerned, however I will offer my approach to acheiving the same thing you are trying to do using the DAO 3.5 Reference (it works with 3.6 too).

Sub DeleteRecord(plonRecordID As Long)
  Dim dbExample As Database
  Dim rsExample As Recordset
  Dim strQuery As String
  
  strQuery = "DELETE FROM Records WHERE RecordID=" & plonRecordID
  
  Set dbExample = OpenDatabase("C:\Example Project\Example.mdb")
  Set rsExample = dbExample.OpenRecordset(strQuery, dbOpenDynaset)
End Sub



Regards,

Anaru

22-02-2010 at 10:43 AM
View Profile Send Email to User Show All Posts | Quote Reply
LEKO
Level: Trainee

Registered: 22-02-2010
Posts: 2
icon Re: Execute dont work with vb6 and access 2000, why?

Im getting no valid operation error with that.

22-02-2010 at 06:51 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 607
icon Re: Execute dont work with vb6 and access 2000, why?

Hi LEKO,
It looks as though your SQL statement may not be properly constructed. "WHERE" statements should be enclosed in brackets :-
sql = "DELETE FROM PERSONAS WHERE ((codigopersona = " & codigoRP & ") And (CodigoC = 1) And (NumeroC = 1) And CodigoD = 1))"
Also, if the value in the Field "codigopersona" is a String then you should surround the Variable codigoRP with single quote marks :-
sql = "DELETE FROM PERSONAS WHERE ((codigopersona = '" & codigoRP & "') And (CodigoC = 1) And (NumeroC = 1) And CodigoD = 1))"


____________________________
multi-tasking - the ability to hang more than one app. at the same time.

24-02-2010 at 04:54 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Execute dont work with vb6 and access 2000, why?
Next Topic (i have one question ?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2011 Andrea Tincaniborder