InnoSetup - test połączenia z bazą danych Postgress

0

Witam, chciałbym zrobić przycisk w InnoSetup, btnTestConnect który miałby za zadanie po wypełnieniu pól tekstowych sprawdzić połączenie z bazą postgress.
Wiem jak to zrobić do mssql, natomiast nie wiem jak to zrobić do postgress

0
Adamek Adam napisał(a):

Pomysł 1)
http://www.jrsoftware.org/ishelp/index.php?topic=scriptdll

using System;
using System.Runtime.InteropServices;
using RGiesecke.DllExport;

namespace Mydll
{
    public class Mydll
    {
    [DllExport("MyDllFunc", CallingConvention=CallingConvention.StdCall)]
    public static int myDllFunc(string server, string port, string user, string pass, string database )
	{		  
			try
			{
				string connectionString
					= String.Format(
					"Server={0};Port={1};User Id={2};Password={3};Database={4};",
					server,
					port,
					user,
					pass,
					database );

				Npgsql.NpgsqlConnection conn = new Npgsql.NpgsqlConnection( connectionString );

				conn.Open();
				conn.Close();
				return 0;
			}
			catch (Exception ex)
			{
				return 1;
			}
		
      }
} 

w Inno Setup

function MyDllFuncSetup(server: String; port: String; user: String; pass: String; db: String ): integer;
external 'MyDllFunc@files:MyDll.dll stdcall setuponly';

function NextButtonClick(CurPage: Integer): Boolean;
var
  hWnd: Integer;
  sServer: String;
  sPort: String;
  sUser: String;
  sPass: String;
  sDb: String;
  itest: Integer;

  begin
  if CurPage = wpWelcome then begin

    sServer := '127.0.0.1';
    sPort := '5432';
    sUser := 'postgres'
    sPass := '****'
    sDb := 'postgres';
    //MessageBox(hWnd, 'Hello from Windows API function', 'MessageBoxA', MB_OK or MB_ICONINFORMATION);

    itest := MyDllFuncSetup(sServer, sPort, sUser, sPass, sDb);
 
   log('return: ' + IntToStr(itest));

  end;
  Result := True;
end;
 

Niestety po wykonaniu zgłasza mi wyjątek external exception E0434352

0

Google podpowiada iż E0434352 ma zwiazek z .net

  1. przetestuj DLL w prostej aplikacji delphi , działa ?
  2. uruchom instalator w taki sposób aby VS pokazał Ci gdzie jest błąd w Twoim projekcie c# i zobacz krok po kroku co sie dzieje)
2

Zacznijmy od tego że jeżeli juz tworzysz zewnętrzną DLL to dlaczego nie w Delphi tylko w C# pod .NET chyba po to aby samemu sobie stwarzać problemy.

1 użytkowników online, w tym zalogowanych: 0, gości: 1