Setting up ODBC programmatically


G

googo man

Hi
I setup an ODBC programmatically as follows. The problem is that i
need to replace the line where it says "UID"="ops$" with the
following:
"UID"="ops$" + %username%

it doesn't work. Any idea what i can do to append the username?
thanks



reg import file1.txt

---- File1.txt ---
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources]
"Oracle"="Microsoft ODBC for Oracle"

[HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\Oracle]
"Driver"="C:\\WINDOWS\\System32\\MSORCL32.dll"
"Description"="Oracle ODBC to access oclprd"
"UID"="ops$"
"Server"="oclprd"
 
Ad

Advertisements

J

J. P. Gilliver (John)

In message
Hi
I setup an ODBC programmatically as follows. The problem is that i
need to replace the line where it says "UID"="ops$" with the
following:
"UID"="ops$" + %username%

it doesn't work. Any idea what i can do to append the username?
thanks
[]
Two thoughts - from general programming experience, not
registry-specific, so neither may help:

1. "UID"="ops$%username%"
2. "UID"="ops$ " + %username% (i. e. with a space?)
--
J. P. Gilliver. UMRA: 1960/<1985 MB++G.5AL-IS-P--Ch++(p)[email protected]+Sh0!:`)DNAf

I have suffered from being misunderstood, but I would have suffered a hell of a
lot more if I had been understood. -Clarence Darrow, lawyer and author
(1857-1938)
 
T

Tim Meddick

If you want to change the line in the registry [*.reg] file, you either
need to create a REG_EXPAND_SZ (right-click > "New" > "Expandable String
Value") in the Registry Editor (regedit.exe) or (if you have quoted the
*exact* line you want included) you can use the modified registry script I
have included below...

Either of which, by using an Expandable String Value, will take account of
the fact that the parameter should be replaced by the system variable
%USERNAME%.


------------------- copy between lines -------------------

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources]
"Oracle"="Microsoft ODBC for Oracle"

[HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\Oracle]
"Driver"="C:\\WINDOWS\\System32\\MSORCL32.dll"
"Description"="Oracle ODBC to access oclprd"
"UID"==hex(2):22,00,6f,00,70,00,73,00,24,00,22,00,20,00,2b,00,20,00,25,00,75,00,\
73,00,65,00,72,00,6e,00,61,00,6d,00,65,00,25,00,00,00
"Server"="oclprd"

------------------- copy between lines -------------------

==

Cheers, Tim Meddick, Peckham, London. :)
 
Ad

Advertisements

G

googo man

Hi Guys,

I will give you more details of what i am trying to achieve. My goal
is to allow the user to set their own ODBC without having to come to
me. The script I included above works perfectly for Microsoft SQL
Server (with the appropriate changes of course).
Now for Oracle, let's say my windows user name is john, my oracle
login name is ops$john.

1. "UID"="ops$%username%"
2. "UID"="ops$ " + %username% (i. e. with a space?)

With suggestion number 1, I end up with ops$%username% as the user
name, so %username% is treated as a value rather than a system
variable.
With suggestion number 2, the entire line is ignored and i get a blank
entry in the odbc.

any other ideas? of course if i give up i'll have the ops$ entered for
them and they just enter the rest themselves, but it would be nice to
have the whole thing done for them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top