pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: PostgreSQL and Access - relink
3+ messages / 3 participants
[nested] [flat]
* Re: PostgreSQL and Access - relink
@ 2006-04-18 14:29 Hakan Kocaman <Hakan.Kocaman@digame.de>
0 siblings, 0 replies; 3+ messages in thread
From: Hakan Kocaman @ 2006-04-18 14:29 UTC (permalink / raw)
To: Jonathan Blitz <jb@anykey.co.il>; pgsql-odbc
Hi,
see codesnippet below.
we use this to relink tables which are partionend on month-base.
Views would be more elegant, but it's an legacy app, where we
sometimes put some effort to use the features of a real DBMS like PG.
The information about the tables(foeignname, localname,..) is in another table.
Public Function create_tbl_defs(foreign_name As String, local_name As String, Optional Aktuell As Boolean = True) As Boolean
Dim Monat As String
Dim vormonat As String
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim strConnect As String
Dim db_inf As db_info
Dim rtn As Boolean
'On Error GoTo create_tbl_defs_Error
' Prüfen ob es eine Monatstabelle ist die immer wieder neu eingebunden werden soll
If Aktuell Then
If InStr(local_name, "_aktuellv") > 0 Then
' Wenn der Localname mit aktellv aufhören sollte wird der vormonat genommen
get_monext Monat, vormonat
foreign_name = foreign_name & vormonat
Else
' Der aktuelle Monat wird aus der tblmonate geholt
get_monext Monat
foreign_name = foreign_name & Monat
End If
End If
' Tabellen verknüpfen
db_inf = get_db_info(gl_db_name)
On Error Resume Next
strConnect = "ODBC;DRIVER={PostgreSQL}" _
& ";SERVER=" & db_inf.ip _
& ";DATABASE=" & db_inf.dbname _
& ";UID=" & db_inf.uid _
& ";PWD=" & db_inf.pwd & ";"
Set db = CurrentDb()
Set tdf = db.CreateTableDef(local_name)
tdf.SourceTableName = foreign_name
tdf.connect = strConnect
db.TableDefs.Append tdf
db.TableDefs.Refresh
'Application.RefreshDatabaseWindow
If Err.Number = 3011 Then
If MsgBox("Die Tabelle " & foreign_name & " konnte nicht gefunden werden." & _
vbCrLf & "Wahrscheinlich ist sie auf dem Server nicht vorhanden." & _
vbCrLf & "Soll das Einbinden der Tabellen abgebrochen werden (Ja) " & _
vbCrLf & "oder soll die Tabelle ignoriert werden (Nein)?", vbYesNo, "Tabelle nicht gefunden") = vbYes _
Then
rtn = False
Else
rtn = True
End If
Else
If Err.Number <> 0 Then
GoTo create_tbl_defs_Error
Else
rtn = True
End If
End If
On Error GoTo 0
Application.RefreshDatabaseWindow
create_tbl_defs = rtn
On Error GoTo 0
Set tdf = Nothing
Set db = Nothing
Exit Function
create_tbl_defs_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure create_tbl_defs of VBA Dokument Form_frmHauptseite"
Set tdf = Nothing
Set db = Nothing
create_tbl_defs = False
End Function
HTH
Hakan Kocaman
Software-Development
digame.de GmbH
Richard-Byrd-Str. 4-8
50829 Köln
Tel.: +49 (0) 221 59 68 88 31
Fax: +49 (0) 221 59 68 88 98
Email: hakan.kocaman@digame.de
> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Jonathan Blitz
> Sent: Tuesday, April 18, 2006 4:57 PM
> To: pgsql-odbc@postgresql.org
> Subject: [ODBC] PostgreSQL and Access - relink
>
>
> I have an Access project linked to a PostgreSQL database
> (linked tables).
>
> I need to be able to switch dynamitically between one
> PostgreSQL database
> and another according to the request from the user.
>
> Anyone have any code that will do this?
>
> I assume it will require me to re-link all the tables.
>
> Jonathan Blitz
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
^ permalink raw reply [nested|flat] 3+ messages in thread
* PostgreSQL and Access - relink
@ 2006-04-18 14:57 Jonathan Blitz <jb@anykey.co.il>
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Blitz @ 2006-04-18 14:57 UTC (permalink / raw)
To: pgsql-odbc
I have an Access project linked to a PostgreSQL database (linked tables).
I need to be able to switch dynamitically between one PostgreSQL database
and another according to the request from the user.
Anyone have any code that will do this?
I assume it will require me to re-link all the tables.
Jonathan Blitz
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: PostgreSQL and Access - relink
@ 2006-04-18 15:43 Campbell, Greg <greg.campbell@us.michelin.com>
parent: Jonathan Blitz <jb@anykey.co.il>
0 siblings, 0 replies; 3+ messages in thread
From: Campbell, Greg @ 2006-04-18 15:43 UTC (permalink / raw)
To: Jonathan Blitz <jb@anykey.co.il>; +Cc: pgsql-odbc
I have used the AttachDSNLessTable function from the Microsoft knowledge base article: 892490.
Just Google: Access DSNless connection 892490
Cut the function and paste the function. Then you can call it from you application and use the fact that
it provides for the tables alias (local) name to smooth out the difference between linked table naming
conventions ("mytable" instead of "public_mytable"(PostgreSQL) or "dbo_mytable"(SQL Server), or
"myuser_mytable"(oracle)).
Jonathan Blitz wrote:
> I have an Access project linked to a PostgreSQL database (linked tables).
>
> I need to be able to switch dynamitically between one PostgreSQL database
> and another according to the request from the user.
>
> Anyone have any code that will do this?
>
> I assume it will require me to re-link all the tables.
>
> Jonathan Blitz
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
Attachments:
greg.campbell.vcf (text/x-vcard, 239B) download
begin:vcard
fn:Greg Campbell
n:Campbell;Greg
org:Michelin North America - US5 Lexington;ENG-ASE
email;internet:greg.campbell@us.michelin.com
title:ASE Systems Engineer
tel;work:803-951-5561/x75561
x-mozilla-html:FALSE
version:2.1
end:vcard
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-04-18 15:43 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-04-18 14:29 Re: PostgreSQL and Access - relink Hakan Kocaman <Hakan.Kocaman@digame.de>
2006-04-18 14:57 PostgreSQL and Access - relink Jonathan Blitz <jb@anykey.co.il>
2006-04-18 15:43 ` Campbell, Greg <greg.campbell@us.michelin.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox