Strona: [  << <   1   > >>  ]  z  1     
Autor Temat: Używanie baz .mdb
andrey
Łódź



Typ: neutral
Postów: 295
Zarejestrowany: Mar 2003
Używanie baz .mdb

W jaki sposób używać baz danych Access na komputerach na których nie ma zainstalowanego Ms Office? Bez Accessa nie mam pliku System.mwd który instalowany jest z pakietem a bez niego nie jestem wstanie ustalić zabezpieczeń bazy Jet.


_____________________________________________
http://www.carbondesign.pl/ - rowery poziome, trójkołówce, handbike-i, tuning, akcesoria

26-03-2003 17:50
Pokaż profil andrey  Wyślij email do andrey   Odwiedź stronę andrey       3078613
anonim




Typ: Nie zarejestrowany

DAO

Sub DAOChangePassword()

  Dim wks As Workspace
  Dim usr As DAO.User

  ' Open the workspace, specifying the system database to use

  DBEngine.SystemDB = _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"
  Set wks = DBEngine.CreateWorkspace("", "Admin", ""

  ' Change the password for the user Admin
  wks.Users("Admin".NewPassword "", "password"

End Sub

ADOX

Sub ADOChangePassword()

  Dim cat As New ADOX.Catalog

  ' Open the catalog, specifying the system database to use
  cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=.\NorthWind.mdb;Jet OLEDB:System database=" & _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"

  ' Change the password for the user Admin
  cat.Users("Admin".ChangePassword "", "password"

End Sub


DAO

Sub DAOChangeDatabasePassword()

  ' Make sure there isn't already a file with the
  ' name of the compacted database.
  If Dir(".\NewNorthWind.mdb" <> "" Then _
      Kill ".\NewNorthWind.mdb"

  ' Basic compact - creating new database named newnwind
  DBEngine.CompactDatabase ".\NorthWind.mdb", _
      ".\NewNorthWind.mdb", , , ";pwd=password;"

  ' Delete the original database
  Kill ".\NorthWind.mdb"

  ' Rename the file back to the original name
  Name ".\NewNorthWind.mdb" As ".\NorthWind.mdb"

End Sub

JRO

Sub JROChangeDatabasePassword()

  Dim je As New JRO.JetEngine

  ' Make sure there isn't already a file with the
  ' name of the compacted database.
  If Dir(".\NewNorthWind.mdb" <> "" Then _
      Kill ".\NewNorthWind.mdb"

  ' Compact the database specifying the new database password
  je.CompactDatabase "Data Source=.\NorthWind.mdb;", _
      "Data Source=.\NewNorthWind.mdb;" & _
      "Jet OLEDBatabase Password=password"

  ' Delete the original database
  Kill ".\NorthWind.mdb"

  ' Rename the file back to the original name
  Name ".\NewNorthWind.mdb" As ".\NorthWind.mdb"

End Sub


Sub DAOChangeDatabasePassword2()

  Dim db As DAO.Database

  Set db = DBEngine.OpenDatabase(".\NorthWind.mdb", True)
  db.NewPassword "", "password"
  db.Close

End Sub


DAO

Sub DAOCreateUser()

  Dim wks As DAO.Workspace

  ' Open a workspace
  DBEngine.SystemDB = _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"
  Set wks = DBEngine.CreateWorkspace("", "Admin", "password"

  ' Create the user and append it to the Users collection
  wks.Users.Append wks.CreateUser("MyUser", "xNewUser", "password"

End Sub

ADOX

Sub ADOCreateUser()

  Dim cat As New ADOX.Catalog

  ' Open the catalog, specifying the system database to use
  cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=.\NorthWind.mdb;Jet OLEDB:System database=" & _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW;" & _
      "User Id=Admin;Password=password;"

  ' Create the new user and append it to the users collection
  cat.Users.Append "MyUser", "password"

End Sub


ADO

Sub ADOCreateUser2()

  Dim cmd As New ADODB.Command

  ' Create the Command
  cmd.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=.\NorthWind.mdb;Jet OLEDB:System database=" & _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW;" & _
      "User Id=Admin;Password=password;"

  ' Execute the DDL security command
  cmd.CommandText = "CREATE USER MyUser MyPW MyPID"
  cmd.Execute

End Sub


DAO

Sub DAOAddUserToNewGroup()

  Dim wks As DAO.Workspace

  ' Open the workspace
  DBEngine.SystemDB = _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"
  Set wks = DBEngine.CreateWorkspace("", "Admin", "password"

  ' Create a new group
  wks.Groups.Append wks.CreateGroup("MyGroup", "xMyGroup"

  ' Add the user to the new group
  wks.Users("MyUser".Groups.Append _
      wks.Users("MyUser".CreateGroup("MyGroup"

End Sub

ADOX

Sub ADOAddUserToNewGroup()

  Dim cat As New ADOX.Catalog

  ' Open the catalog
  cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=.\NorthWind.mdb;User Id=Admin;" & _
      "Password=password;Jet OLEDB:System database=" & _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"

  ' Create a new group
  cat.Groups.Append "MyGroup"

  ' Add the user to the new group
  cat.Users("MyUser".Groups.Append "MyGroup"

End Sub


DAO

Sub DAOSetUserObjectPermissions()

  Dim db As DAO.Database
  Dim wks As DAO.Workspace
  Dim doc As DAO.Document

  ' Open the database
  DBEngine.SystemDB = _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"
  Set wks = DBEngine.CreateWorkspace("", "Admin", "password"
  Set db = wks.OpenDatabase(".\NorthWind.mdb"

  ' Set permissions for MyUser on the Customers table
  Set doc = db.Containers("Tables".Documents("Customers"
  doc.UserName = "MyUser"
  doc.Permissions = dbSecRetrieveData Or dbSecInsertData _
      Or dbSecReplaceData Or dbSecDeleteData

End Sub

ADOX

Sub ADOSetUserObjectPermissions()

  Dim cat As New ADOX.Catalog

  ' Open the catalog
  cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=.\NorthWind.mdb;User Id=Admin;" & _
      "Password=password;Jet OLEDB:System database=" & _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"

  ' Set permissions for MyUser on the Customers table
  cat.Users("MyUser".SetPermissions "Customers", adPermObjTable, _
      adAccessSet, adRightRead Or adRightInsert Or adRightUpdate _
      Or adRightDelete

End Sub


DAO ADOX
dbSecNoAccess adRightNone
dbSecFullAccess adRightFull
dbSecDelete adRightDrop
dbSecReadSec adRightReadPermissions
dbSecWriteSec adRightWritePermissions
dbSecWriteOwner adRightWriteOwner
dbSecCreate adRightCreate
dbSecReadDef adRightReadDesign
dbSecWriteDef adRightWriteDesign
dbSecRetrieveData adRightRead
dbSecInsertData adRightInsert
dbSecReplaceData adRightUpdate
dbSecDeleteData adRightDelete
dbSecDBAdmin adRightFull
dbSecDBCreate adRightCreate
dbSecDBExclusive adRightExclusive
dbSecDBOpen adRightRead


DAO

Sub DAOSetDatabasePermissions()

  Dim db As DAO.Database
  Dim wks As DAO.Workspace
  Dim doc As DAO.Document

  ' Open the database
  DBEngine.SystemDB = _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"
  Set wks = DBEngine.CreateWorkspace("", "Admin", "password"
  Set db = wks.OpenDatabase(".\NorthWind.mdb"

  ' Set permissions for MyUser on the current database
  Set doc = db.Containers("Databases".Documents("MSysDB"
  doc.UserName = "MyUser"
  doc.Permissions = dbSecDBExclusive

End Sub

ADOX

Sub ADOSetDatabasePermissions()

  Dim cat As New ADOX.Catalog

  ' Open the catalog
  cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=.\NorthWind.mdb;User Id=Admin;" & _
      "Password=password;Jet OLEDB:System database=" & _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"

  ' Set permissions for MyUser on the current database
  cat.Users("MyUser".SetPermissions "", adPermObjDatabase, _
      adAccessSet, adRightExclusive

End Sub


DAO

Sub DAOSetUserContainerPermissions()

  Dim db As DAO.Database
  Dim wks As DAO.Workspace
  Dim ctr As DAO.Container

  ' Open the database
  DBEngine.SystemDB = _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"
  Set wks = DBEngine.CreateWorkspace("", "Admin", "password"
  Set db = wks.OpenDatabase(".\NorthWind.mdb"

  ' Set permissions for MyUser on the Tables Container
  Set ctr = db.Containers("Tables"
  ctr.UserName = "MyUser"
  ctr.Inherit = True
  ctr.Permissions = dbSecRetrieveData Or dbSecInsertData _
      Or dbSecReplaceData Or dbSecDeleteData

End Sub

ADOX

Sub ADOSetUserContainerPermissions()

  Dim cat As New ADOX.Catalog

  ' Open the catalog
  cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=.\NorthWind.mdb;User Id=Admin;" & _
      "Password=password;Jet OLEDB:System database=" & _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"

  ' Set permissions for MyUser on the Tables Container
  cat.Users("MyUser".SetPermissions Null, adPermObjTable, _
      adAccessSet, adRightRead Or adRightInsert Or adRightUpdate _
      Or adRightDelete, adInheritNone

End Sub


DAO

Sub DAOGetObjectOwner()

  Dim db As DAO.Database
  Dim wks As DAO.Workspace

  ' Open the database
  DBEngine.SystemDB = _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"
  Set wks = DBEngine.CreateWorkspace("", "Admin", "password"
  Set db = wks.OpenDatabase(".\NorthWind.mdb"

  ' Print the owner of the Customers table
  Debug.Print db.Containers("Tables".Documents("Customers".Owner

End Sub

ADOX

Sub ADOGetObjectOwner()

  Dim cat As New ADOX.Catalog

  ' Open the catalog
  cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=.\NorthWind.mdb;User Id=Admin;" & _
      "Password=password;Jet OLEDB:System database=" & _
      "C:\Program Files\Microsoft Office\Office\SYSTEM.MDW"

  ' Print the owner of the Customers table
  Debug.Print cat.GetObjectOwner("Customers", adPermObjTable)

End Sub

14-04-2003 22:42
  
Wrobel



Typ: neutral
Postów: 44
Zarejestrowany: Sep 2002
WOW !!!

Co za listing !!!
Wydaje mi się, że gostek wie jak dostać się do baz danych za pomocą ADO lub DAO (te dwa sposoby w zupełności mu wystarczą). Nie panikuj z plikiem system.mdw, bo możesz-powinieneś dołączyć go do pakietu instalacyjnego swego programu i instalować go w określonej lokalizacji np. w katalogu programu. Dodatkowo proponuję zmienić nazwę pliku system.mdw na jakikolwiek - jaki Ci pasuje, w ten sposób unikniesz kłopotów z pomyłką podaczas podłączenia się do grupy roboczej.
Teraz musisz zaisntalować MDAC_TYP.exe i Jet4.0 pliki te możesz pobrać darmowo z Microsoftu lub mojej strony (sekcja download).
Powodzenia !!!

23-04-2003 11:41
Pokaż profil Wrobel  Wyślij email do Wrobel   Odwiedź stronę Wrobel  
andrey
Łódź



Typ: neutral
Postów: 295
Zarejestrowany: Mar 2003
Dzięki

Sorry, że nie miałem czasu wcześniej podziekować


_____________________________________________
http://www.carbondesign.pl/ - rowery poziome, trójkołówce, handbike-i, tuning, akcesoria

07-05-2003 14:52
Pokaż profil andrey  Wyślij email do andrey   Odwiedź stronę andrey       3078613
Wszystkich odpowiedzi: 3 :: Maxymalnie na stronę: 20
Strona: [  << <   1   > >>  ]  z  1