473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Need code to update tables on server database

Hello,

I'm trying to check for and add a field to a table to a back end database
through code. The problem I've been faced with is changing permissions,
because I have to use administer permissions to change the design, then
remove the delete permissions when the design has been changed.

I have to do it in code because there are several sites that need an
automated update (as opposed to manually adding the field). The platform is
Access XP. The database has a simple password on it and is not using any
particular work group, just the standard System.mdw that is installed with
Access.

I have cut and pasted the code I've written (using DAO 3.6) but I'm
receiving an error that no one has been able to help me out with (Error
3358: Can't open the Microsoft Jet engine workgroup information file.), so
that's the reason why I'm looking for an alternative.

Time is running out on me, so any help or new direction would be greatly
appreciated.

Thanks!
(Here is the code that I was trying to use....)

Private Sub ChangeDB(strDatabase as string)
On Error GoTo ChangeDB_Err
Dim db As DAO.Database
Dim docloop As Document
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim yFound As Boolean

Set db = OpenDatabase(strDatabase), False, False, ";PWD=" & conDbPwd)

With db.Containers!Tables
For Each docloop In .Documents

If docloop.Name = "UserDefaults" Then

docloop.Permissions = 1048319

Set tdf = db.TableDefs("UserDefaults")
For Each fld In tdf.Fields
If fld.Name = "DefaultFolder" Then yFound = True
Next fld

If Not yFound Then
Set fld = tdf.CreateField("DefaultFolder",
dbInteger)
tdf.Fields.Append fld
End If

docloop.Permissions = 196213
End If
Next docloop
End With
Set db = Nothing
ChangeDb_Exit:
cmdFinish.Enabled = True
Exit Sub

ChangeDb_Err:
MsgBox Err.Number & ": " & Err.Description, vbCritical, "ERROR"
Resume ChangeDb_Exit

End Sub
Nov 14 '05 #1
4 2177
Jozef wrote:
Hello,

I'm trying to check for and add a field to a table to a back end database
through code. The problem I've been faced with is changing permissions,
because I have to use administer permissions to change the design, then
remove the delete permissions when the design has been changed.

I have to do it in code because there are several sites that need an
automated update (as opposed to manually adding the field). The platform is
Access XP. The database has a simple password on it and is not using any
particular work group, just the standard System.mdw that is installed with
Access.

I have cut and pasted the code I've written (using DAO 3.6) but I'm
receiving an error that no one has been able to help me out with (Error
3358: Can't open the Microsoft Jet engine workgroup information file.), so
that's the reason why I'm looking for an alternative.

Time is running out on me, so any help or new direction would be greatly
appreciated.

Thanks!
(Here is the code that I was trying to use....)

Private Sub ChangeDB(strDatabase as string)
On Error GoTo ChangeDB_Err
Dim db As DAO.Database
Dim docloop As Document
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim yFound As Boolean

Set db = OpenDatabase(strDatabase), False, False, ";PWD=" & conDbPwd)

With db.Containers!Tables
For Each docloop In .Documents

If docloop.Name = "UserDefaults" Then

docloop.Permissions = 1048319

Set tdf = db.TableDefs("UserDefaults")
For Each fld In tdf.Fields
If fld.Name = "DefaultFolder" Then yFound = True
Next fld

If Not yFound Then
Set fld = tdf.CreateField("DefaultFolder",
dbInteger)
tdf.Fields.Append fld
End If

docloop.Permissions = 196213
End If
Next docloop
End With
Set db = Nothing
ChangeDb_Exit:
cmdFinish.Enabled = True
Exit Sub

ChangeDb_Err:
MsgBox Err.Number & ": " & Err.Description, vbCritical, "ERROR"
Resume ChangeDb_Exit

End Sub

You might want to add
DBEngine.SystemDB = "system.mdw"
at the top of the sub. It might or might not make a bit of difference.

I did this
? dbSecFullAccess
1048575
but I'm using A97. What is 1048319? Maybe give full access, see if
that makes a diff.

Also, why don't you store the value of the Permissions to a variable and
reset it to that when you leave after updating? What is
.Permissions = 196213

Why not
x = .Permissions
'process
.Permissions = x
It seems to make more sense than whatever you are attempting to do with
a 196213.

I think you'd be better off as a programmer in you used intrinsic
constants names in your code. Less confusing. The code you use is like
"Hey, Jozef! Gimme a 192482" You wouldn't know what a 192482 is from a
hole in the ground.

Nov 14 '05 #2
Are you running this in Access VBA or as a VB utility?

Put line numbers on the lines so that your error message
can report the line where the error occurs:

Err.Description & vbcrlf & "at ChangeDB." & erl

Use a complete declaration for the openobject method:

application.dbengine.opendatabase

Do you have permission to change the table permission?

use privDBEngine or createObject("dao.dbengine") to
open a different login.

I just use a different login with design permission
on the tables. You can add the owner to the current
workgroup, make the changes, then delete the owner.
Not very secure, but then if you wanted good security
you probably wouldn't use Access.

(david)
"Jozef" <me@you.com> wrote in message
news:aBSdf.106208$S4.102109@edtnps84...
Hello,

I'm trying to check for and add a field to a table to a back end database
through code. The problem I've been faced with is changing permissions,
because I have to use administer permissions to change the design, then
remove the delete permissions when the design has been changed.

I have to do it in code because there are several sites that need an
automated update (as opposed to manually adding the field). The platform
is Access XP. The database has a simple password on it and is not using
any particular work group, just the standard System.mdw that is installed
with Access.

I have cut and pasted the code I've written (using DAO 3.6) but I'm
receiving an error that no one has been able to help me out with (Error
3358: Can't open the Microsoft Jet engine workgroup information file.), so
that's the reason why I'm looking for an alternative.

Time is running out on me, so any help or new direction would be greatly
appreciated.

Thanks!
(Here is the code that I was trying to use....)

Private Sub ChangeDB(strDatabase as string)
On Error GoTo ChangeDB_Err
Dim db As DAO.Database
Dim docloop As Document
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim yFound As Boolean

Set db = OpenDatabase(strDatabase), False, False, ";PWD=" & conDbPwd)

With db.Containers!Tables
For Each docloop In .Documents

If docloop.Name = "UserDefaults" Then

docloop.Permissions = 1048319

Set tdf = db.TableDefs("UserDefaults")
For Each fld In tdf.Fields
If fld.Name = "DefaultFolder" Then yFound = True
Next fld

If Not yFound Then
Set fld = tdf.CreateField("DefaultFolder",
dbInteger)
tdf.Fields.Append fld
End If

docloop.Permissions = 196213
End If
Next docloop
End With
Set db = Nothing
ChangeDb_Exit:
cmdFinish.Enabled = True
Exit Sub

ChangeDb_Err:
MsgBox Err.Number & ": " & Err.Description, vbCritical, "ERROR"
Resume ChangeDb_Exit

End Sub

Nov 14 '05 #3
Thanks guys, the DBEngine.SystemDB = "system.mdw" line worked.

The permission 196213 removes delete capability. The reason why I called
this one out specifically is that there are some remote tables that are not
currently set to this permission set. Outside of that, the code I pasted
was the "It's not working so I'm tweaking the hell out of it" version of the
code.

Thanks!
"Jozef" <me@you.com> wrote in message
news:aBSdf.106208$S4.102109@edtnps84...
Hello,

I'm trying to check for and add a field to a table to a back end database
through code. The problem I've been faced with is changing permissions,
because I have to use administer permissions to change the design, then
remove the delete permissions when the design has been changed.

I have to do it in code because there are several sites that need an
automated update (as opposed to manually adding the field). The platform
is Access XP. The database has a simple password on it and is not using
any particular work group, just the standard System.mdw that is installed
with Access.

I have cut and pasted the code I've written (using DAO 3.6) but I'm
receiving an error that no one has been able to help me out with (Error
3358: Can't open the Microsoft Jet engine workgroup information file.), so
that's the reason why I'm looking for an alternative.

Time is running out on me, so any help or new direction would be greatly
appreciated.

Thanks!
(Here is the code that I was trying to use....)

Private Sub ChangeDB(strDatabase as string)
On Error GoTo ChangeDB_Err
Dim db As DAO.Database
Dim docloop As Document
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim yFound As Boolean

Set db = OpenDatabase(strDatabase), False, False, ";PWD=" & conDbPwd)

With db.Containers!Tables
For Each docloop In .Documents

If docloop.Name = "UserDefaults" Then

docloop.Permissions = 1048319

Set tdf = db.TableDefs("UserDefaults")
For Each fld In tdf.Fields
If fld.Name = "DefaultFolder" Then yFound = True
Next fld

If Not yFound Then
Set fld = tdf.CreateField("DefaultFolder",
dbInteger)
tdf.Fields.Append fld
End If

docloop.Permissions = 196213
End If
Next docloop
End With
Set db = Nothing
ChangeDb_Exit:
cmdFinish.Enabled = True
Exit Sub

ChangeDb_Err:
MsgBox Err.Number & ": " & Err.Description, vbCritical, "ERROR"
Resume ChangeDb_Exit

End Sub

Nov 15 '05 #4
Jozef wrote:
Thanks guys, the DBEngine.SystemDB = "system.mdw" line worked.

The permission 196213 removes delete capability. The reason why I called
this one out specifically is that there are some remote tables that are not
currently set to this permission set. Outside of that, the code I pasted
was the "It's not working so I'm tweaking the hell out of it" version of the
code.

Thanks!

Glad that worked! It was an interesting problem and the solution ended
up being something minor. And I learned something from your code,
haven't worked programmatically with security.

"Jozef" <me@you.com> wrote in message
news:aBSdf.106208$S4.102109@edtnps84...
Hello,

I'm trying to check for and add a field to a table to a back end database
through code. The problem I've been faced with is changing permissions,
because I have to use administer permissions to change the design, then
remove the delete permissions when the design has been changed.

I have to do it in code because there are several sites that need an
automated update (as opposed to manually adding the field). The platform
is Access XP. The database has a simple password on it and is not using
any particular work group, just the standard System.mdw that is installed
with Access.

I have cut and pasted the code I've written (using DAO 3.6) but I'm
receiving an error that no one has been able to help me out with (Error
3358: Can't open the Microsoft Jet engine workgroup information file.), so
that's the reason why I'm looking for an alternative.

Time is running out on me, so any help or new direction would be greatly
appreciated.

Thanks!
(Here is the code that I was trying to use....)

Private Sub ChangeDB(strDatabase as string)
On Error GoTo ChangeDB_Err
Dim db As DAO.Database
Dim docloop As Document
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim yFound As Boolean

Set db = OpenDatabase(strDatabase), False, False, ";PWD=" & conDbPwd)

With db.Containers!Tables
For Each docloop In .Documents

If docloop.Name = "UserDefaults" Then

docloop.Permissions = 1048319

Set tdf = db.TableDefs("UserDefaults")
For Each fld In tdf.Fields
If fld.Name = "DefaultFolder" Then yFound = True
Next fld

If Not yFound Then
Set fld = tdf.CreateField("DefaultFolder",
dbInteger)
tdf.Fields.Append fld
End If

docloop.Permissions = 196213
End If
Next docloop
End With
Set db = Nothing
ChangeDb_Exit:
cmdFinish.Enabled = True
Exit Sub

ChangeDb_Err:
MsgBox Err.Number & ": " & Err.Description, vbCritical, "ERROR"
Resume ChangeDb_Exit

End Sub


Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Irvin | last post by:
I new to ASP.net and am using the following code to attempt to update an Access 2000 mdb. The code does make it through the code following "try". NO rows are updated. There is a row with the...
5
by: yvan | last post by:
Approximately once a month, a client of ours sends us a bunch of comma-delimited text files which I have to clean up and then import into their MS SQL database. All last week, I was using a Cold...
3
by: swingingming | last post by:
Hi, for 5 weeks, I finished my mdb project. Thanks to all you guys. Now, I would like to put it on a server then 5-6 people can share it. I heard about the splitting back-end database, put it on a...
6
by: Babu Mannaravalappil | last post by:
Can somebody please help me figure out why the following method exceptions out? Execution at the line marked with ********** hangs for about 15 seconds and then I get an error that says an...
7
by: Jack Addington | last post by:
I've got a fairly simple application implementation that over time is going to get a lot bigger. I'm really trying to implement it in a way that will facilitate the growth. I am first writing a...
5
by: manmit.walia | last post by:
Hello All, I am stuck on a conversion problem. I am trying to convert my application which is written in VB.NET to C# because the project I am working on currently is being written in C#. I tried...
10
by: cj | last post by:
I have lots of tables to copy from one server to another. The new tables have been created to match the old ones. I practiced with one table. I created the select command (select * from tableA)...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
0
by: toyin | last post by:
hello, pls help look through this code its not inserting the record in dataset into the another database. i want to insert the row in the dataset into another table in another database. pls help....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.