WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ODBC
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Updating an INI File over the Network

Keywords:    network INI files

Question:

I wrote a Winbatch which changes some entries in the ODBC.INI file. But this doesn't work. I can call the destination file ODBC1.INI or ODBC2.INI. Then it works, but as soon as I define it ODBC.INI (as the real one) no entries are made. ???????

I'm not writing to my local odbc.ini but to one that is on another drive (one of the user's home directories). For example,

iniwrt............ i:\JOHNDOE\WFW311\ODBC.INI

Answer:

WARNING! WARNING! WARNING!

Although the initialization files are simple ASCII text files that can be modified with any text editor, they should only be changed using the tools provided specifically for ODBC administration.

The same is true of the registry entries. Text editors or the registry editor can be used to view the contents of ODBC configurations, but attempts to modify the information using these editors can be disastrous.

Often the user is unaware of interactions between different areas of the configuration, and manual editing provides no error checking. An example of this is with the SQL Server driver. If a network address and library are entered in the configuration dialog box, they are not only saved as part of the ODBC.INI information, but they are also written to the SQLSERVER section of the WIN.INI file.

Future revisions of the driver could change the options and keyword-value pairs without notice. All of these reasons justify the need to not edit the ODBC configurations by hand.

In addition to all that, INI files are funny. They are not written right away. They are cached in memory.

I assume you are using the iniwritepvt functions. It's really not a good idea to edit the INI file over the network. That being said, here are some considerations to keep in mind:

  1. ALWAYS use a full path when referring to ini files that are not in your windows directory.

  2. Add the following to your code:
    inifile="I:\JOHNDOE\WFW311\ODBC.INI"
    
    and the magic line that forces the update:
    IniWritePvt("","","",inifile)
    
    The blank parameters is a secret Windows key to cause the ini file to be written from memory immediately.

Updating Local NT INI Files:

In NT some INI files are mapped to the registry instead of a real disk file.
  1. Try setting a value with iniwritepvt, reboot and then try to read the value with inireadpvt.

  2. Look in the registry. Search for the data you wrote to the ini file.

  3. Search your windows directory for the data.

  4. Make sure the odbc.ini is not read-only.

Article ID:   W12544
Filename:   Updating ODBC.INI File over the Network.txt
File Created: 2017:07:28:12:58:34
Last Updated: 2001:01:09:15:04:58