|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Hi
I am trying to find a way to view the connection information in a system DSN ODBC Connection to a SQL Server DB. In fact, the only thing I really need to view is the name of the server.
I am wanting to pull the server name from the ODBC connection so that I can display it in my applciation to avoid confusion over where the frontend application is pointing (since I occasionally reconfigure the ODBC to point at the same DB on other servers (Dev, Test, Prod etc).
Is this possible? Any suggestions welcomed.
Glenn
|
|
DSN information is stored in the registry in either HCKU\Software\ODBC or HCLM\Software\ODBC.
You might want to look into going DSN-less, though. See http://www.accessmvp.com/djsteele/DSNLessLinks.html for one approach.
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please)
"Glenn" <gmcintosh[ at ]xtra.co.nz> wrote in message news:1153169475.780707.30380[ at ]i42g2000cwa.googlegroups.com...
[Quoted Text] > Hi > > I am trying to find a way to view the connection information in a > system DSN ODBC Connection to a SQL Server DB. In fact, the only thing > I really need to view is the name of the server. > > I am wanting to pull the server name from the ODBC connection so that I > can display it in my applciation to avoid confusion over where the > frontend application is pointing (since I occasionally reconfigure the > ODBC to point at the same DB on other servers (Dev, Test, Prod etc). > > Is this possible? Any suggestions welcomed. > > Glenn >
|
|
An API for reading from the registry is SQLGetPrivateProfileString: and API for reading file dsn's is SQLReadFileDSN
(david)
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> wrote in message news:%23uqEkweqGHA.4932[ at ]TK2MSFTNGP05.phx.gbl...
[Quoted Text] > DSN information is stored in the registry in either HCKU\Software\ODBC or > HCLM\Software\ODBC. > > You might want to look into going DSN-less, though. See > http://www.accessmvp.com/djsteele/DSNLessLinks.html for one approach. > > -- > Doug Steele, Microsoft Access MVP > http://I.Am/DougSteele> (no private e-mails, please) > > > "Glenn" <gmcintosh[ at ]xtra.co.nz> wrote in message > news:1153169475.780707.30380[ at ]i42g2000cwa.googlegroups.com... > > Hi > > > > I am trying to find a way to view the connection information in a > > system DSN ODBC Connection to a SQL Server DB. In fact, the only thing > > I really need to view is the name of the server. > > > > I am wanting to pull the server name from the ODBC connection so that I > > can display it in my applciation to avoid confusion over where the > > frontend application is pointing (since I occasionally reconfigure the > > ODBC to point at the same DB on other servers (Dev, Test, Prod etc). > > > > Is this possible? Any suggestions welcomed. > > > > Glenn > > > >
|
|
Hi Doug
Many thanks for that, I can see the server name in the registry as you instructed. Sadly I have no experience in making API calls from Access, and after a quick search for SQLGetPrivateProfileString the code in the resulting posts looks fairly scary to implement. Are you able to point me to some code that would pull the server name from the registry via an Access VBA function or proc?
Regards Glenn
david[ at ]epsomdotcomdotau wrote:
[Quoted Text] > An API for reading from the registry is SQLGetPrivateProfileString: > and API for reading file dsn's is SQLReadFileDSN > > (david) > > "Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> wrote in message > news:%23uqEkweqGHA.4932[ at ]TK2MSFTNGP05.phx.gbl... > > DSN information is stored in the registry in either HCKU\Software\ODBC or > > HCLM\Software\ODBC. > > > > You might want to look into going DSN-less, though. See > > http://www.accessmvp.com/djsteele/DSNLessLinks.html for one approach. > > > > -- > > Doug Steele, Microsoft Access MVP > > http://I.Am/DougSteele> > (no private e-mails, please) > > > > > > "Glenn" <gmcintosh[ at ]xtra.co.nz> wrote in message > > news:1153169475.780707.30380[ at ]i42g2000cwa.googlegroups.com... > > > Hi > > > > > > I am trying to find a way to view the connection information in a > > > system DSN ODBC Connection to a SQL Server DB. In fact, the only thing > > > I really need to view is the name of the server. > > > > > > I am wanting to pull the server name from the ODBC connection so that I > > > can display it in my applciation to avoid confusion over where the > > > frontend application is pointing (since I occasionally reconfigure the > > > ODBC to point at the same DB on other servers (Dev, Test, Prod etc). > > > > > > Is this possible? Any suggestions welcomed. > > > > > > Glenn > > > > > > >
|
|
To be honest, I've never used SQLGetPrivateProfileString.
There's code at "The Access Web" for reading from the registry, though. Check http://www.mvps.org/access/api/api0015.htm
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please)
"Glenn" <gmcintosh[ at ]xtra.co.nz> wrote in message news:1153263255.807773.130590[ at ]p79g2000cwp.googlegroups.com...
[Quoted Text] > Hi Doug > > Many thanks for that, I can see the server name in the registry as you > instructed. Sadly I have no experience in making API calls from Access, > and after a quick search for SQLGetPrivateProfileString the code in the > resulting posts looks fairly scary to implement. Are you able to point > me to some code that would pull the server name from the registry via > an Access VBA function or proc? > > Regards > Glenn > > > david[ at ]epsomdotcomdotau wrote: >> An API for reading from the registry is SQLGetPrivateProfileString: >> and API for reading file dsn's is SQLReadFileDSN >> >> (david) >> >> "Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> wrote in message >> news:%23uqEkweqGHA.4932[ at ]TK2MSFTNGP05.phx.gbl... >> > DSN information is stored in the registry in either HCKU\Software\ODBC >> > or >> > HCLM\Software\ODBC. >> > >> > You might want to look into going DSN-less, though. See >> > http://www.accessmvp.com/djsteele/DSNLessLinks.html for one approach. >> > >> > -- >> > Doug Steele, Microsoft Access MVP >> > http://I.Am/DougSteele>> > (no private e-mails, please) >> > >> > >> > "Glenn" <gmcintosh[ at ]xtra.co.nz> wrote in message >> > news:1153169475.780707.30380[ at ]i42g2000cwa.googlegroups.com... >> > > Hi >> > > >> > > I am trying to find a way to view the connection information in a >> > > system DSN ODBC Connection to a SQL Server DB. In fact, the only >> > > thing >> > > I really need to view is the name of the server. >> > > >> > > I am wanting to pull the server name from the ODBC connection so that >> > > I >> > > can display it in my applciation to avoid confusion over where the >> > > frontend application is pointing (since I occasionally reconfigure >> > > the >> > > ODBC to point at the same DB on other servers (Dev, Test, Prod etc). >> > > >> > > Is this possible? Any suggestions welcomed. >> > > >> > > Glenn >> > > >> > >> > >
|
|
The code at the the link below worked perfectly.
Thanks Doug and Dave for your suggestions.
Cheers Glenn
Douglas J. Steele wrote:
[Quoted Text] > To be honest, I've never used SQLGetPrivateProfileString. > > There's code at "The Access Web" for reading from the registry, though. > Check http://www.mvps.org/access/api/api0015.htm> > -- > Doug Steele, Microsoft Access MVP > http://I.Am/DougSteele> (no private e-mails, please) > > > "Glenn" <gmcintosh[ at ]xtra.co.nz> wrote in message > news:1153263255.807773.130590[ at ]p79g2000cwp.googlegroups.com... > > Hi Doug > > > > Many thanks for that, I can see the server name in the registry as you > > instructed. Sadly I have no experience in making API calls from Access, > > and after a quick search for SQLGetPrivateProfileString the code in the > > resulting posts looks fairly scary to implement. Are you able to point > > me to some code that would pull the server name from the registry via > > an Access VBA function or proc? > > > > Regards > > Glenn > > > > > > david[ at ]epsomdotcomdotau wrote: > >> An API for reading from the registry is SQLGetPrivateProfileString: > >> and API for reading file dsn's is SQLReadFileDSN > >> > >> (david) > >> > >> "Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> wrote in message > >> news:%23uqEkweqGHA.4932[ at ]TK2MSFTNGP05.phx.gbl... > >> > DSN information is stored in the registry in either HCKU\Software\ODBC > >> > or > >> > HCLM\Software\ODBC. > >> > > >> > You might want to look into going DSN-less, though. See > >> > http://www.accessmvp.com/djsteele/DSNLessLinks.html for one approach. > >> > > >> > -- > >> > Doug Steele, Microsoft Access MVP > >> > http://I.Am/DougSteele> >> > (no private e-mails, please) > >> > > >> > > >> > "Glenn" <gmcintosh[ at ]xtra.co.nz> wrote in message > >> > news:1153169475.780707.30380[ at ]i42g2000cwa.googlegroups.com... > >> > > Hi > >> > > > >> > > I am trying to find a way to view the connection information in a > >> > > system DSN ODBC Connection to a SQL Server DB. In fact, the only > >> > > thing > >> > > I really need to view is the name of the server. > >> > > > >> > > I am wanting to pull the server name from the ODBC connection so that > >> > > I > >> > > can display it in my applciation to avoid confusion over where the > >> > > frontend application is pointing (since I occasionally reconfigure > >> > > the > >> > > ODBC to point at the same DB on other servers (Dev, Test, Prod etc). > >> > > > >> > > Is this possible? Any suggestions welcomed. > >> > > > >> > > Glenn > >> > > > >> > > >> > > >
|
|
|
[Quoted Text] > To be honest, I've never used SQLGetPrivateProfileString.
It's just the same as GetPrivateProfileString, ported to the registry in the change to Win95, given another name to be part of the ODBC api set.
And SQLReadFileDSN is ??? the same as GetPrivateProfileString, ??? but given a new name in the change to Win95, for stuff that still wants to read from an INI file, which is what a file DSN is.
??? SQLReadFileDSN may read only from the ODBC section of a DSN ???
(david)
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> wrote in message news:O3fdq7rqGHA.2464[ at ]TK2MSFTNGP03.phx.gbl... > To be honest, I've never used SQLGetPrivateProfileString. > > There's code at "The Access Web" for reading from the registry, though. > Check http://www.mvps.org/access/api/api0015.htm > > -- > Doug Steele, Microsoft Access MVP > http://I.Am/DougSteele > (no private e-mails, please) > > > "Glenn" <gmcintosh[ at ]xtra.co.nz> wrote in message > news:1153263255.807773.130590[ at ]p79g2000cwp.googlegroups.com... >> Hi Doug >> >> Many thanks for that, I can see the server name in the registry as you >> instructed. Sadly I have no experience in making API calls from Access, >> and after a quick search for SQLGetPrivateProfileString the code in the >> resulting posts looks fairly scary to implement. Are you able to point >> me to some code that would pull the server name from the registry via >> an Access VBA function or proc? >> >> Regards >> Glenn >> >> >> david[ at ]epsomdotcomdotau wrote: >>> An API for reading from the registry is SQLGetPrivateProfileString: >>> and API for reading file dsn's is SQLReadFileDSN >>> >>> (david) >>> >>> "Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> wrote in message >>> news:%23uqEkweqGHA.4932[ at ]TK2MSFTNGP05.phx.gbl... >>> > DSN information is stored in the registry in either HCKU\Software\ODBC >>> > or >>> > HCLM\Software\ODBC. >>> > >>> > You might want to look into going DSN-less, though. See >>> > http://www.accessmvp.com/djsteele/DSNLessLinks.html for one approach. >>> > >>> > -- >>> > Doug Steele, Microsoft Access MVP >>> > http://I.Am/DougSteele >>> > (no private e-mails, please) >>> > >>> > >>> > "Glenn" <gmcintosh[ at ]xtra.co.nz> wrote in message >>> > news:1153169475.780707.30380[ at ]i42g2000cwa.googlegroups.com... >>> > > Hi >>> > > >>> > > I am trying to find a way to view the connection information in a >>> > > system DSN ODBC Connection to a SQL Server DB. In fact, the only >>> > > thing >>> > > I really need to view is the name of the server. >>> > > >>> > > I am wanting to pull the server name from the ODBC connection so >>> > > that I >>> > > can display it in my applciation to avoid confusion over where the >>> > > frontend application is pointing (since I occasionally reconfigure >>> > > the >>> > > ODBC to point at the same DB on other servers (Dev, Test, Prod etc). >>> > > >>> > > Is this possible? Any suggestions welcomed. >>> > > >>> > > Glenn >>> > > >>> > >>> > >> > >
|
|
hi Doug, i have an access 2000 fe and sql server 2000 BE, i wen to your website and copy and pasted your code in a module and pressed ctrl + G and typed, fix connections "servername", "database name" and pressed enter just like you said, but i get an error message that says compile error, expected identifier...also in the code i changed where it says server name with my server name and database name with my database name.. .am i missing anything else?
Jenny
Douglas J. Steele wrote:
[Quoted Text] > DSN information is stored in the registry in either HCKU\Software\ODBC or > HCLM\Software\ODBC. > > You might want to look into going DSN-less, though. See > http://www.accessmvp.com/djsteele/DSNLessLinks.html for one approach. > > -- > Doug Steele, Microsoft Access MVP > http://I.Am/DougSteele> (no private e-mails, please) > > > "Glenn" <gmcintosh[ at ]xtra.co.nz> wrote in message > news:1153169475.780707.30380[ at ]i42g2000cwa.googlegroups.com... > > Hi > > > > I am trying to find a way to view the connection information in a > > system DSN ODBC Connection to a SQL Server DB. In fact, the only thing > > I really need to view is the name of the server. > > > > I am wanting to pull the server name from the ODBC connection so that I > > can display it in my applciation to avoid confusion over where the > > frontend application is pointing (since I occasionally reconfigure the > > ODBC to point at the same DB on other servers (Dev, Test, Prod etc). > > > > Is this possible? Any suggestions welcomed. > > > > Glenn > >
|
|
Are you saying you changed the code itself to include your server and database names? That's not the intent. Leave the code exactly as it is, and when you type in the Immediate window, simply replace "MyServer" with the name of your server (in quotes) and "MyDatabase" with the name of your database (again, in quotes). For example, if your server is named SQLServer1 and your database is TestDB, use:
FixConnections "SQLServer1", "TestDB"
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please)
"Jessica" <ralvarado[ at ]printmedia-inc.com> wrote in message news:1153850989.355325.214260[ at ]p79g2000cwp.googlegroups.com...
[Quoted Text] > hi Doug, i have an access 2000 fe and sql server 2000 BE, i wen to your > website and copy and pasted your code in a module and pressed ctrl + G > and typed, fix connections "servername", "database name" and pressed > enter just like you said, but i get an error message that says compile > error, expected identifier...also in the code i changed where it says > server name with my server name and database name with my database > name.. .am i missing anything else? > > Jenny > > Douglas J. Steele wrote: >> DSN information is stored in the registry in either HCKU\Software\ODBC or >> HCLM\Software\ODBC. >> >> You might want to look into going DSN-less, though. See >> http://www.accessmvp.com/djsteele/DSNLessLinks.html for one approach. >> >> -- >> Doug Steele, Microsoft Access MVP >> http://I.Am/DougSteele>> (no private e-mails, please) >> >> >> "Glenn" <gmcintosh[ at ]xtra.co.nz> wrote in message >> news:1153169475.780707.30380[ at ]i42g2000cwa.googlegroups.com... >> > Hi >> > >> > I am trying to find a way to view the connection information in a >> > system DSN ODBC Connection to a SQL Server DB. In fact, the only thing >> > I really need to view is the name of the server. >> > >> > I am wanting to pull the server name from the ODBC connection so that I >> > can display it in my applciation to avoid confusion over where the >> > frontend application is pointing (since I occasionally reconfigure the >> > ODBC to point at the same DB on other servers (Dev, Test, Prod etc). >> > >> > Is this possible? Any suggestions welcomed. >> > >> > Glenn >> > >
|
|
|