ATENÇÃO usuários de Access com problemas de corrupção

Delphi

09/12/2004

Eu tinha muitos problemas de corrupção de arquivos MDB na rede e fazendo pesquisa na NET encotrei dois links interessantes:

[url]http://support.microsoft.com/default.aspx?scid=kb;en-us;Q303519[/url]

Este da algumas dicas para evitar a corrupção (em access 97 mas tem para outras versões).

[url]http://support.microsoft.com/default.aspx?scid=kb;pt-br;176670[/url]

Este é para baixar um utilitário que mostra as maquinas conectadas ao BD e mostra aquelas suspeitas de estarem provocando a corrupção. É bem legal e me ajudou a identificar a máquina que estava gerando um inferno no meu trabalho.

Alem do utilitário vem uma DLL para poder fazer esta leitura pelo nosso sistema, com duas funções:

Declare Function LDBUser_GetUsers Lib “MSLDBUSR.DLL” (lpszUserBuffer() As String, ByVal lpszFilename As String, ByVal nOptions As Long) As Integer Declare Function LDBUser_GetError Lib “MSLDBUSR.DLL” (ByVal nErrorNo As Long) As String Function Parameters in VB/Access Integer LDBUser_GetUsers ( lpszUserBuffer() As String,‘ Returned array list of users ByVal lpszFilename As String, ‘ The name of the MDB file ByVal nOptions As Long‘ specifies the return options ) lpszUserBuffer() – This is a standard array string defined in VB/Access. The only unusual characteristic of this string is that it needs to be defined as a dynamic array. This can be accomplished using the REDIM statement. e.g. Sub Foo() ReDim lpszUserBuffer(1) As String End Sub The purpose of defining a dynamic array is to allow the MSLDBUSR.DLL to redimension the array in its code base to match the number of users that are to be returned. lpszFilename -- This is the name of the filename with its associated database extension (MDB, MDW, MDA, etc…). A corresponding LDB file must exist, otherwise LDBUser_GetUsers will return an error. nOptions -- Specifies the type of users that are returned into lpsaUserList. 1=All users who have logged in since the LDB file was created 2=Only users who are currently logged in 4=Only users who are causing the database file to be corrupt 8=Just returns the count of users. No users are returned in the BSTR array String LDBUser_GetError ( ByVal nErrorNo As Long // The error number returned by LDBUser_GetUsers )


Beleza!!!

Só que quando eu fui tentar ler os usuários conectados, recebi um código de erro: ´Invalid argument´

O código que estou usando é o seguinte:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    aUserList : array of shortstring;
  end;

var
  Form1: TForm1;

implementation

function LDBUser_GetUsers (lpszUserBuffer : array of shortstring; lpszFilename : shortstring; nOptions : integer) : integer; external ´MSLDBUSR.DLL´;

function LDBUser_GetError (nErrorNo : integer) : shortstring; external ´MSLDBUSR.DLL´;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
   nUser : integer;
begin
   nUser := LDBUser_GetUsers(aUserList, PChar(´c:\dados\principal.mdb´), 1);

   if nUser < 0 then
      ShowMessage(LDBUser_GetError(nUser))
   else
      ShowMessage(aUserList[0]);
end;

end.


Eu sei que para testar é preciso baixar a DLL, mas se alguem quiser testar me manda um e-mail que eu envio só a DLL.

Agradeço qualquer ajuda

Obrigado,

Quadrado
equadrado@hotmail.com


Quadrado

Quadrado

Curtidas 0
POSTAR