diff --git a/connection.c b/connection.c
index 131a0e7..63af8ca 100644
--- a/connection.c
+++ b/connection.c
@@ -312,6 +312,7 @@ CC_copy_conninfo(ConnInfo *ci, const ConnInfo *sci)
 	NAME_TO_NAME(ci->password, sci->password);
 	CORR_STRCPY(port);
 	CORR_STRCPY(sslmode);
+    CORR_STRCPY(service);
 	CORR_STRCPY(onlyread);
 	CORR_STRCPY(fake_oid_index);
 	CORR_STRCPY(show_oid_column);
@@ -2510,6 +2511,10 @@ LIBPQ_connect(ConnectionClass *self)
 			opts[cnt] = "sslmode";
 			vals[cnt++] = ci->sslmode;
 	}
+	if (ci->service[0])
+	{
+		opts[cnt] = "service";		vals[cnt++] = ci->service;
+	}
 	if (NAME_IS_VALID(ci->password))
 	{
 		opts[cnt] = "password";	vals[cnt++] = SAFE_NAME(ci->password);
diff --git a/connection.h b/connection.h
index 20d0bbb..f8aa808 100644
--- a/connection.h
+++ b/connection.h
@@ -218,6 +218,7 @@ typedef struct
 	pgNAME		password;
 	char		port[SMALL_REGISTRY_LEN];
 	char		sslmode[16];
+	char		service[MEDIUM_REGISTRY_LEN];
 	char		onlyread[SMALL_REGISTRY_LEN];
 	char		fake_oid_index[SMALL_REGISTRY_LEN];
 	char		show_oid_column[SMALL_REGISTRY_LEN];
diff --git a/dlg_specific.c b/dlg_specific.c
index 6ab7464..cdc1a0d 100644
--- a/dlg_specific.c
+++ b/dlg_specific.c
@@ -289,6 +289,7 @@ inolog("hlen=%d", hlen);
 			strcpy(protocol_and, "7.4");
 		olen = snprintf(&connect_string[hlen], nlen, ";"
 			INI_SSLMODE "=%s;"
+			INI_SERVICE "=%s;"
 			INI_READONLY "=%s;"
 			INI_PROTOCOL "=%s;"
 			INI_FAKEOIDINDEX "=%s;"
@@ -323,6 +324,7 @@ inolog("hlen=%d", hlen);
 			INI_XAOPT "=%d"	/* XAOPT */
 #endif /* _HANDLE_ENLIST_IN_DTC_ */
 			,ci->sslmode
+			,ci->service
 			,ci->onlyread
 			,protocol_and
 			,ci->fake_oid_index
@@ -660,6 +662,8 @@ copyAttributes(ConnInfo *ci, const char *attribute, const char *value)
 				break;
 		}
 	}
+	else if (stricmp(attribute, INI_SERVICE) == 0 || stricmp(attribute, ABBR_SERVICE) == 0)
+		strcpy(ci->service, value);
 	else if (stricmp(attribute, INI_ABBREVIATE) == 0)
 		unfoldCXAttribute(ci, value);
 #ifdef	_HANDLE_ENLIST_IN_DTC_
@@ -1000,6 +1004,9 @@ getDSNinfo(ConnInfo *ci, char overwrite)
 	if (ci->sslmode[0] == '\0' || overwrite)
 		SQLGetPrivateProfileString(DSN, INI_SSLMODE, "", ci->sslmode, sizeof(ci->sslmode), ODBC_INI);
 
+	if (ci->service[0] == '\0' || overwrite)
+		SQLGetPrivateProfileString(DSN, INI_SERVICE, "", ci->service, sizeof(ci->service), ODBC_INI);
+
 #ifdef	_HANDLE_ENLIST_IN_DTC_
 	if (ci->xa_opt < 0 || overwrite)
 	{
@@ -1270,6 +1277,10 @@ writeDSNinfo(const ConnInfo *ci)
 								 INI_SSLMODE,
 								 ci->sslmode,
 								 ODBC_INI);
+	SQLWritePrivateProfileString(DSN,
+								 INI_SERVICE,
+								 ci->service,
+								 ODBC_INI);
 	sprintf(temp, "%d", ci->keepalive_idle);
 	SQLWritePrivateProfileString(DSN,
 								 INI_KEEPALIVETIME,
diff --git a/dlg_specific.h b/dlg_specific.h
index 30ea389..ceb3bea 100644
--- a/dlg_specific.h
+++ b/dlg_specific.h
@@ -157,6 +157,8 @@ extern "C" {
 #define ABBR_LOWERCASEIDENTIFIER	"C9"
 #define INI_SSLMODE			"SSLmode"
 #define ABBR_SSLMODE			"CA"
+#define INI_SERVICE			"service"
+#define ABBR_SERVICE			"SE"
 #define INI_EXTRAOPTIONS		"AB"
 #define INI_LOGDIR			"Logdir"
 #define INI_GSSAUTHUSEGSSAPI		"GssAuthUseGSS"
