PC Review


Reply
Thread Tools Rate Thread

Custom Database Properties

 
 
jez123456
Guest
Posts: n/a
 
      25th Nov 2008
Hi Experts

I have an access adp project connected to a sql server 2000 database. I need
to store a few local values in the adp project. I have used the Custom
Database Properties to save these values. How do I retrieve these items using
ADO code? Or can it only be done for access mdb files?
Many thanks

 
Reply With Quote
 
 
 
 
Sylvain Lafontaine
Guest
Posts: n/a
 
      25th Nov 2008
To my knowledge, you cannot directly access the Custom Database Properties
from an ADP project. Maybe it's possible to do so by using the DSOFile.dll
library but I never checked personally. However, it's quite easy to add
custom properties to an ADP file by using the following code. Notice that
usually, you will find on the internet a version that use the Err_Handler in
order to determine if a named property already exists in the collection when
doing an insert. In the following version, this Err_Handler has been
replace by a Loop that scans the names already in the collection before
trying to make an insert. LogError() is any logging function that you might
use for logging errors. The varPropType (replaced here with
varPropType_Dummy) is not used because all properties (values) are stored as
string; not as Integer, String, etc.


' 2455 is for ADP, not for MDB.
Private Const cerrPropertyNotFound As Integer = 2455

Public Sub Debug_DisplayProperties()

Dim db As CurrentProject
Set db = Application.CurrentProject

Dim i
For i = 0 To db.Properties.Count - 1
Debug.Print db.Properties(i).name & ": " & db.Properties(i)
Next

End Sub


Public Sub SetProperty(ByVal strPropName As String, _
ByVal varPropType_Dummy As Integer, _
ByVal varPropValue As Variant)

Const cProcedureName As String = "SetProperty"
On Error GoTo Err_Handler

Dim db As CurrentProject
Set db = Application.CurrentProject

If (IsNull(varPropValue)) Then varPropValue = ""

Dim i
For i = 0 To db.Properties.Count - 1
If (db.Properties(i).name = strPropName) Then
db.Properties(strPropName).Value = varPropValue
GoTo Exit_Sub
End If
Next

db.Properties.Add strPropName, varPropValue

Exit_Sub:
On Error GoTo 0
Set db = Nothing
Exit Sub

Err_Handler:
' Err_Handler: used on older version.

Select Case err
Case cerrPropertyNotFound
db.Properties.Add strPropName, varPropValue

Case Else
' Call LogError(Err.Number, Err.Description, _
cModuleName & cProcedureName)
End Select

Resume Exit_Sub

End Sub


' GetProperty() : return True if the property exists in the collection,
' the property itself is returned in an ByRef parameter.

Public Function GetProperty(ByVal strPropName As String, _
ByRef strPropValue As Variant) As Boolean

Const cProcedureName As String = "GetProperty"
On Error GoTo Err_Handler

Dim db As CurrentProject
Set db = Application.CurrentProject

Dim i
For i = 0 To db.Properties.Count - 1
If (db.Properties(i).name = strPropName) Then
strPropValue = db.Properties(strPropName)
GetProperty = True
GoTo Exit_Function
End If
Next

GetProperty = False

Exit_Function:
On Error GoTo 0
Set db = Nothing
Exit Function

Err_Handler:
GetProperty = False

Select Case err
Case cerrPropertyNotFound
Case Else
' Call LogError(Err.Number, Err.Description, _
cModuleName & cProcedureName)

End Select

Resume Exit_Function

End Function

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: sylvain aei ca (fill the blanks, no spam please)


"jez123456" <(E-Mail Removed)> wrote in message
news:B428766F-CC3A-4891-B3B2-(E-Mail Removed)...
> Hi Experts
>
> I have an access adp project connected to a sql server 2000 database. I
> need
> to store a few local values in the adp project. I have used the Custom
> Database Properties to save these values. How do I retrieve these items
> using
> ADO code? Or can it only be done for access mdb files?
> Many thanks
>



 
Reply With Quote
 
a a r o n _ k e m p f
Guest
Posts: n/a
 
      22nd Dec 2008
why don't you just store these custom properties in a table?

I typically store session-level informaiton in a table called
'SysAppSettings' that has a PK INT DEFAULT @@SPID




On Nov 25, 7:43*am, jez123456 <jez123...@discussions.microsoft.com>
wrote:
> Hi Experts
>
> I have an access adp project connected to a sql server 2000 database. I need
> to store a few local values in the adp project. I have used the Custom
> Database Properties to save these values. How do I retrieve these items using
> ADO code? Or can it only be done for access mdb files?
> Many thanks


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
custom database properties =?Utf-8?B?bW9tMnRocmVl?= Microsoft Access VBA Modules 0 7th Feb 2006 03:19 AM
How to get and set Custom Database properties in ADP? Bill Microsoft Access ADP SQL Server 5 10th Dec 2005 10:15 PM
Making Custom Control Properties Visible in Visual Studio's Properties Palette Nathan Sokalski Microsoft ASP .NET 0 17th Oct 2005 03:05 AM
Database Properties, Custom =?Utf-8?B?Um9iZXJ0X0xfUm9zcw==?= Microsoft Access 2 10th Jun 2005 11:50 PM
Custom Database Properties Ronald Dodge Microsoft Access VBA Modules 5 12th Dec 2003 10:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:57 AM.