Avatar billede perfi Nybegynder
24. januar 2001 - 11:36 Der er 11 kommentarer og
1 løsning

ODBC adgang

Hej
Jeg skal til at lave et applikation program der dynamiske skal linke et eksisterende program til odbc drivere til databaser der ligger andetsteds på netværket. Er der en der kan komme med en rigtig god ide til hvorledes man bedst skulle bygge det op.?? Uden at sige at jeg ikke selv har en idé.
Overordnet havde jeg tænkt at i programmet skulle man selv indskrive stien og benytte det indskrevet som en variabel der stemmer overens med det eksisterende programmets struktur. Er det en god måde at gøre det på eller er der en mere fiks måde at gøre det på. Jeg benytter Borland builder 4.0. ??? 
Avatar billede soepro Nybegynder
24. januar 2001 - 12:51 #1
Du kan direkte vælge ODBC-driveren i stedet for BDE\'ns aliaser når du f.eks. definerer en TTable. Mht. til de forskellige parametre som ODBC-driveren kræver for at kunne fungere, kan disse \"overføres\" til ODBC-driveren vha. \'Param\' property\'en. Herved kan du godt have en generisk TTable adgang til en hvilken som helt ODBC-database - du skal \"bare\" sikre dig at brugeren vælger den rigtige ODBC-driver og dernæst angiver det rette sti.

Hvis det kun er en bestemt type database, er det hele jo blot så meget nemmere.

BEMÆRK: Nogle databasetyper, f.eks. paradox, tillader dig direkte at angive HELE stien til databasen.
Avatar billede soepro Nybegynder
24. januar 2001 - 13:01 #2
Sorry - det er naturligvis TDatabase komponenter hvori man kan vælge ODBC driveren direkte, og overføre de forskellige parametre i \'Params\' property\'en.
Avatar billede perfi Nybegynder
24. januar 2001 - 22:34 #3
Hej igen

Mit problem er at jeg ikke kan komme ud over min egen computers drev. Jeg ville gerne ind på \"andre computere\" for at hente en shared database eller anden type, som odbc driver skal spille op imod.
Jeg bruger en Directorylistbox og driveCombobox.
Avatar billede soepro Nybegynder
25. januar 2001 - 10:56 #4
Kan du se de andre drev i f.eks. StiFinder ??? Det er en forudsætning (i forhold til DirectoryListbox og DriveComboBox) at dine netdrev figurerer med et bogstav - hvis de ikke gør de, skal du først kalde den Windows API der tildeler et drev bogstav til din netværkspath. (Check Windows API SDK hjælpen, der følger med C++ Builder - eller skriv igen, så skal jeg prøve at finde den.)
Avatar billede perfi Nybegynder
25. januar 2001 - 11:21 #5
Ja, der er hul igennem til andre drev på netværket. Men vil lige tjekke hjælpen du ref. til
perfi.
Avatar billede perfi Nybegynder
25. januar 2001 - 11:52 #6
Hej igen
Det jeg er ude i er at når man vælge en ODBC driver via kontrolpanel i windows, kan man trykke på netværk og på det tidspunkt oprette et fjerndrev. Og ikke på forhånd erklære drevet. Ikke fordi det gør så meget, men....jeg vil gerne at mit program skal kunne gøre tilsvarende...Nok en tro kopi at windows, men ikke destro mindre en nødvændighed, da vi på forhånd, ved kompilingen af programmet, ikke kender stien til databaserne.
Avatar billede soepro Nybegynder
25. januar 2001 - 12:13 #7
Kommer her:

he WNetAddConnection2 function makes a connection to a network resource. The function can redirect a local device to the network resource.

The WNetAddConnection2 function supersedes the WNetAddConnection function. If you pass a handle to a window that the provider of network resources can use as an owner window for dialog boxes, use the WNetAddConnection3 function.

DWORD WNetAddConnection2(

    LPNETRESOURCE lpNetResource,    // points to structure that specifies connection details
    LPCTSTR lpPassword,    // points to password string
    LPCTSTR lpUsername,    // points to user name string
    DWORD dwFlags     // set of bit flags that specify connection options
  );   


Parameters

lpNetResource

Points to a NETRESOURCE structure that specifies details of the proposed connection: information about the network resource, the local device, and the network resource provider.
You must specify the following members of the NETRESOURCE structure:

Member    Description
dwType    Specifies the type of network resource to connect to. If lpLocalName points to a non-empty string, this member can be RESOURCETYPE_DISK or RESOURCETYPE_PRINT. If lpLocalName is NULL or points to an empty string, dwType can be RESOURCETYPE_DISK, RESOURCETYPE_PRINT, or RESOURCETYPE_ANY.
lpLocalName    Points to a null-terminated string that specifies the name of a local device to be redirected, such as \"F:\" or \"LPT1\". The string is treated in a case-insensitive manner. If the string is empty or lpLocalName is NULL, the function makes a connection to the network resource without redirecting a local device.
lpRemoteName    Points to a null-terminated string that specifies the network resource to connect to. The string can be up to MAX_PATH characters in length. The string must follow the network provider\'s naming conventions.
lpProvider    Points to a null-terminated string that specifies the network provider to connect to. If lpProvider is NULL or points to an empty string, the operating system attempts to determine the correct provider by parsing the string pointed to by lpRemoteName.
You should set this member only if you know for sure which network provider you want to use. Otherwise, let the operating system determine which provider the network name maps to.
If this member is not NULL, the operating system attempts to make a connection only to the named network provider.


The WNetAddConnection2 function ignores the other members of the NETRESOURCE structure.

lpPassword

Points to a null-terminated string that specifies a password to be used in making the network connection.

If lpPassword is NULL, the function uses the current default password associated with the user specified by lpUserName.
If lpPassword points to an empty string, the function does not use a password.

lpUsername

Points to a null-terminated string that specifies a user name to be used in making the connection.
If lpUserName is NULL, the function uses the default user name. The user context for the process provides the default user name.

The lpUserName parameter is specified when users want to connect to a network resource for which they have been assigned a user name or account other than the default user name or account.

The user-name string represents a security context. It may be specific to a network provider.

dwFlags

A set of bit flags that specify connection options. The following bit flag constant is currently defined:

Value    Meaning
CONNECT_UPDATE_PROFILE    The network resource connection should be remembered. If this bit flag is set, the operating system automatically attempts to restore the connection when the user logs on.The operating system remembers only successful connections that redirect local devices. It does not remember unsuccessful connections or deviceless connections. A deviceless connection occurs when lpLocalName is NULL or points to an empty string.If this bit flag is clear, the operating system will not automatically restore the connection at logon.


Return Values

If the function succeeds, the return value is NO_ERROR.
If the function fails, the return value is an error code. Returning an error code provides compatibility with the behavior of the Windows 3.1 function WNetAddConnection. You can also call the GetLastError function to obtain the (same) error code. One of the following error codes may be returned when WNetAddConnection2 fails:

Value    Meaning
ERROR_ACCESS_DENIED    Access to the network resource was denied.
ERROR_ALREADY_ASSIGNED    The local device specified by lpLocalName is already connected to a network resource.
ERROR_BAD_DEV_TYPE    The type of local device and the type of network resource do not match.
ERROR_BAD_DEVICE    The value specified by lpLocalName is invalid.
ERROR_BAD_NET_NAME    The value specified by lpRemoteName is not acceptable to any network resource provider. The resource name is invalid, or the named resource cannot be located.
ERROR_BAD_PROFILE    The user profile is in an incorrect format.
ERROR_BAD_PROVIDER    The value specified by lpProvider does not match any provider.
ERROR_BUSY    The router or provider is busy, possibly initializing. The caller should retry.
ERROR_CANCELLED    The attempt to make the connection was cancelled by the user through a dialog box from one of the network resource providers, or by a called resource.
ERROR_CANNOT_OPEN_PROFILE    The system is unable to open the user profile to process persistent connections.
ERROR_DEVICE_ALREADY_REMEMBERED    An entry for the device specified in lpLocalName is already in the user profile.
ERROR_EXTENDED_ERROR    A network-specific error occured. Call the WNetGetLastError function to get a description of the error.
ERROR_INVALID_PASSWORD    The specified password is invalid.
ERROR_NO_NET_OR_BAD_PATH    A network component has not started, or the specified name could not be handled.
ERROR_NO_NETWORK    There is no network present.


See Also

WNetAddConnection, WNetAddConnection3, WNetCancelConnection2, WNetGetConnection, WNetGetLastError, NETRESOURCE

hvor NETRESOURCE er:

The NETRESOURCE structure is returned during enumeration of resources on the network and during enumeration of currently connected resources.

typedef struct _NETRESOURCE {  // nr 
    DWORD  dwScope;
    DWORD  dwType;
    DWORD  dwDisplayType;
    DWORD  dwUsage;
    LPTSTR lpLocalName;
    LPTSTR lpRemoteName;
    LPTSTR lpComment;
    LPTSTR lpProvider;
} NETRESOURCE;


Members

dwScope

Specifies the scope of the enumeration. Currently, this member can be one of the following values:

Value    Meaning
RESOURCE_CONNECTED    Currently connected resources (the dwUsage member is undefined).
RESOURCE_GLOBALNET    Resources on the network.
RESOURCE_REMEMBERED    Remembered (persistent) connections (dwUsage is undefined).


dwType

Specifies a bitmask that gives the resource type. Currently, this member can be one of the following values:

Value    Meaning
RESOURCETYPE_ANY    All resources
RESOURCETYPE_DISK    Disk resources
RESOURCETYPE_PRINT    Print resources


dwDisplayType

Specifies how the network object should be displayed in a network browsing user interface. Currently, this member can be the following values:

Value    Meaning
RESOURCEDISPLAYTYPE_DOMAIN   
The object should be displayed as a domain.
RESOURCEDISPLAYTYPE_GENERIC   
The method used to display the object does not matter.
RESOURCEDISPLAYTYPE_SERVER   
The object should be displayed as a server.
RESOURCEDISPLAYTYPE_SHARE   
The object should be displayed as a sharepoint.


dwUsage

Specifies a bitmask that gives the resource usage. This member is defined only if dwScope is RESOURCE_GLOBALNET. Currently, this member can be one of the following values:

Value    Meaning
RESOURCEUSAGE_CONNECTABLE    This is a connectable resource; the name pointed to by the lpRemoteName member can be passed to the WNetAddConnection function to make a network connection.
RESOURCEUSAGE_CONTAINER    This is a container resource; the name pointed to by the lpRemoteName member can be passed to the WNetOpenEnum function to enumerate the resources in the container.


lpLocalName

Points to the name of a local device if the dwScope member is RESOURCE_CONNECTED or RESOURCE_REMEMBERED. This member is NULL if the connection does not use a device. Otherwise, it is undefined.

lpRemoteName

Points to a remote network name if the entry is a network resource.
If the entry is a current or persistent connection, lpRemoteName points to the network name associated with the name pointed to by the lpLocalName member.

lpComment

Points to a provider-supplied comment.

lpProvider

Points to the name of the provider owning this resource. This member can be NULL if the provider name is unknown.



See Also

WNetAddConnection, WNetCloseEnum, WNetEnumResource, WNetOpenEnum
Avatar billede perfi Nybegynder
25. januar 2001 - 12:54 #8
Hej

Her hopper jeg over....Jeg kan se ideen, men det er også det hele. Takker for indsatsen, men  hardcore programmør er jeg ikke. Jeg ville bare gerne vide om der var en komponent i Builderen der kunne mappen drev fra netværk, men der der det ikke ud til at der er, så må man mappe drevet før man opretter ODBC drivere...??
perfi.
Avatar billede soepro Nybegynder
25. januar 2001 - 13:14 #9
Ja, det vil jeg foreslå dig - altså at mappe dine netværksdrev een gang for alle. Herefter kan du snildt bruge DriveComboBox\'en osv. Mht. opsætning af dine ODBC-drivere er det ikke noget krav at den peger på det rigtige drev fra starten af - du kan som skrevet ændre de fleste ting dynamisk - men det er MEGET nemmere blot at gøre de i ODBC-konfiguarionen inde under kontrolpanel\'et.
Avatar billede perfi Nybegynder
25. januar 2001 - 13:21 #10
OK SOEPRO

Det gælder vel ikke om at gøre det sværere for sig selv mere end højest nødvændigt...Så jeg takke for hjælpen.
Jeg lege lidt med et client program til det program der indeholder databaserne, da flere forskellige skal benytte den samme source db. Så det er sådan set ved implementering af client prg. problemerne kommer. Jeg har ikke prøvet dette endnu, derfor denne forespørgsel...SÅ TAK.
Avatar billede soepro Nybegynder
25. januar 2001 - 13:27 #11
Hvis du skal have en central DB-server, er det så ikke COM eller CORBA teknologien du skal kigge på. Ideen med COM-applikationerne er jo netop at have een central applikation som henter og skriver data, og et antal clienter som requester læs eller skriv til databasen derigennem. C++ Builder 4 manualen indeholder en detaljeret beskrivelse af hvordan man gør - og du kan godt debugge programmerne selvom du er i gang med clienten - IDE\'en fortsætter automatisk over i COM-serveren og tilbage igen.
Avatar billede perfi Nybegynder
25. januar 2001 - 13:56 #12
Jo, det er sådan set det jeg skal have gang i...Men der skal ikke kun være adgang fra clients, men også fra selve DB serveren. Ideén har jeg, men skal lige oversættes fra psudo til code....barelige ikk´...
OK perfi
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester