Link to home
Start Free TrialLog in
Avatar of zolpo
zolpo

asked on

Vb application on win98, winXP etc

Hi,
I wrote a VB6 (MDAC 2.6, operating system win98) application that write data into access97 DB, I packeged it, installed it, and it works fine.
I tried to install it on a different computer (using access 2000),
 the installation was successful but when the application tries
to write to the DB I get the following error:
"Runtime error 2147467259 (8000 4005) operation must use
an updateable query"
On Windows XP I cant run it at all!
Could the problem be the differents versions of access, or operating systems?
How can I fix it???
thanx u all


Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Show us your code. It seems that your connection is opened for read-only. Your problem is surely not Access but XP which installed MDAC 2.7. Some properties may have changed their default value.
it is most likely the different versions of Access that are involved.  But, s emoreau says, show us the code, and are you using ADO or DAO?

AW
Avatar of zolpo
zolpo

ASKER

Hi,
Thank U!!!
I'm using ADO,
As to the problem with XP- on XP the program doesn't run at all, on Win98 with access 2000 the runtime error I mentioned before occurs.
I'm not sure the problem is that the connection is opened for read-only couse it works on Win98 with access97 (where I wrote the code).

Here is the code I use to insert into the DB:

Private Sub doLogin(name As String)
    Dim cmd As New ADODB.Command
    Dim strSql As String
    Dim sum As Currency
   
    today = Format(Now, "short date")
    hour = Format(Now, "long time")
    sum = Format(0, "currency")
     
     ' Define a query string
     'Inserting to big table
     strSql = "INSERT INTO entries (username,eDate,month_no,enter,exit,code,shift,occasion,cash,credit) VALUES ("
     strSql = strSql & "'" & name & "',#" & today & "#," & Format(Now, "m") & ",'" & hour & "','" & hour & "',"
     strSql = strSql & 1 & ",'" & shift & "','" & occasion & "', 0,0)"
       
    ' Set up the Command object
     cmd.CommandText = strSql
     cmd.CommandType = adCmdText
     cmd.ActiveConnection = cn
     cmd.Execute
    ' Tidy up
     Set cmd = Nothing
     
    'inserting into backup table
     strSql = "INSERT INTO quickEnter (username,eDate,eTime,code) VALUES ("
     strSql = strSql & "'" & name & "','" & today & "','" & hour & "','" & 1 & "')"
     
     
     cmd.CommandText = strSql
     cmd.CommandType = adCmdText
     cmd.ActiveConnection = cn
     cmd.Execute
    ' Tidy up
     Set cmd = Nothing
End Sub
Thanks again.
Where is your connection (cn) declared and opened?
Avatar of zolpo

ASKER

Hi emoreau,
The connection is declared and opened in module.bas file:

Public cn As ADODB.Connection


Public Sub connectToDB()
    Dim DBpath As String
    Set cn = New ADODB.Connection
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
    DBpath = App.Path & "\DB.mdb"
    strConn = strConn & DBpath
    'strConn = strConn & "d:\keren\ovdim\DB.mdb"
    cn.ConnectionString = strConn
    cn.Open
End Sub

The sub connectToDB is called from  a load form function
Thanx!
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zolpo

ASKER

Hi emoreau!!!
THANKS A LOT!
it works.