Odbc windows 7 data source administrator. ODBC data source management

This book describes Windows Script Host (WSH) version 5.6, which is one of the standard components of Windows XP and can also be installed on earlier versions of Windows. Scripts in VBScript and JScript are provided to illustrate the use of standard WSH 5.6 objects, including creating child processes from scripts and running scripts on remote computers... As more complex examples discusses scripts that work with databases that control Microsoft applications Office organizing graphic user interface using ADSI technologies ( Active Directory Service Interface) and WMI (Windows Management Instrumentation) for solving administrative tasks. The issues of practical work with XML-files and creation of COM-objects are covered. Particular attention is paid to security issues when working with scripts, specific examples of security policy settings are provided. The book comes with a diskette with the source code for most of the examples.

Book:

To access the created DBF table from the WSH script, we will use the ODBC (Open DataBase Connectivity) technology. ODBC is standard remedy Microsoft for working with relational databases of various formats and manufacturers, capable of processing queries to databases in SQL (Structured Query Language, structured query language).

Comment

For an initial acquaintance with the SQL language, we can recommend a book.

First, we need to create an ODBC record in the system to connect to our database, i.e. create a new DSN (Data Source Name). In Windows XP, this is done as follows.

Download Control Panel(Control Panel) Windows (Menu Start(Start)) and switch to the classic view (Figure 9.6).


Fig. 9.6. Classic look Windows XP Control Panel

Sequentially select items Administration(Administrative tools) and Data Sources (ODBC)(Data sources (ODBC)). In the dialog box that appears, select the tab System DSN(System DSN), which will create a DSN accessible to all computer users (Figure 9.7).


Fig. 9.7. ODBC Data Source Administrator on Windows XP

Press the button Add to(Add) and in the window that appears, select Microsoft driver dBase Driver (* .dbf) (fig.9.8).

The other day I ran into such a problem, on windows 7 especially in the starter and home versions, there are no ODBC data sources.

ODBC (Open Database Connectivity) is a database access programming interface (API) developed by Microsoft in collaboration with Simba Technologies based on the Call Level Interface (CLI) specifications developed by SQL Access Group, X / Open and Microsoft. The CLI was subsequently standardized by ISO ISO / IEC 9075-3: 2003. (English) The CLI standard is designed to unify software interaction with a DBMS, to make it independent of the DBMS vendor and software and hardware platform.



In the early 1990s, there were several database vendors, each with its own interface. If the application needed to communicate with multiple data sources, it had to write its own code to interact with each of the databases. To solve this problem, Microsoft and a number of other companies have created a standard interface for receiving and sending to data sources. different types... This interface has been called Open Database Connectivity, or Open Database Connectivity.
With ODBC, application programmers could develop applications to use a single data access interface without worrying about the intricacies of interacting with multiple sources.

That is, the ODBC tab itself is, here is the screen:

And it even opens, but when adding the "System DSN"

There is no choice of databases, as for example on windows XP, there is a choice of only one type of databases, this is SQL, this is not good at all. Because, for example, many bank clients require an ODBC data source from microsoft (mdb). And if you don't choose it, how can you install the bank client on Windows 7 starter or home? Below are two screenshots, one is windows 7 starter, the other is windows XP.

I will say that there is a way out of this situation. Windows 7 starter or home is designed for the home, so it doesn't have the bells and whistles you need to professional programs... Here is the difference in price, if the home or starter version ranges from 2,100 to 3,000 rubles, then the PRO version costs at least twice as much. But you can still put the bank client in Windows 7 starter and home. Just install the bank client, it will create an ODBC data source from Microsoft itself, although it will not be visible in the field. I.e in simple words the field will be empty and the mdb database will be created.

Installing the client bank

After installing the client's bank, it started up fine and worked.

Thus, Windows is a little cunning, that is, hinting to you that to install an ODBC data source, you need to buy a more expensive version, although everything works in starter or home, there is simply no field.

And it even opens, but only when adding the "System DSN":

There is no choice of databases, as for example on Windows XP... It turns out the choice of only one of the types of databases - SQL, and this is not good at all. Because, for example, many bank clients require ODBC data source it is from Microsoft (mdb) !!! And if you don't choose it, how can you set the client's bank to Windows 7 Starter or Windows 7 Home?



For comparison, look at two screenshots, one - Windows 7 Starter, the other is Windows XP.

1) Windows 7 Starter:

2) Windows XP Professional:

Nevertheless, there is a way out of this situation! Versions Windows 7 Starter or Home, are designed for the home, so they do not have those bells and whistles that are needed for professional programs. Here is the difference in price, for comparison: if the cost Home or Starter version of Windows fluctuates between 2,100 - 3,000 rubles, then PRO-version costs at least twice as much.



But you can still put a client bank in Windows 7 Starter and Windows 7 Home... Just install the client bank, it will create itself ODBC data source from Microsoft, although it won't be visible in the field. That is, in simple words, the field will be empty, and the mdb database will be created.

Installing the client bank:

After installing the bank-client, it started up fine and worked.

Thus, Windows is a little cunning, as if hinting to you that to install ODBC data source you need to buy a more expensive version, although everything works in the Starter or Home versions, there is simply no field.

Creating an application that uses a database

Annotation to subsection

The point of this subsection is to enforce laboratory work on creating a database application·

To work with databases, aliases are often used. A database alias is the name of a certain database, which is written in the settings in such a way that to access the tables of this database, it is enough to specify alias. This convenience allows you to easily change the type of database without changing the program text.

Consider the principle of defining a database alias Microsoft Access stored in a file on your hard drive. Let's say we want the borey alias to match the database in the borey.mdb file. We can do this programmatically using the SQLConfigDataSource ODBC API function.

To set an alias in manual mode you must run the ODBC Data Source Administrator (Start \ Settings \ Control Panel \ Administrative Tools \ Data Sources (ODBC)). The administrator window is shown in Figure 6.

Figure 6 - ODBC Data Source Administrator

Next, on the "User DSN" or "System DSN" tab (depending on whether a data source is being created for the current user or for all system users, respectively), click the "Add" button. ·

A list will be displayed installed drivers and their description (Figure 7).

Figure 7 - ODBC Data Source Administrator. Dialogue for creating a new data source

· After clicking on the "Finish" button in the window that opens (Figure 8), you must specify the source name "db" and the path to the file.

Figure 8 - ODBC Data Source Administrator. Dialogue for creating a new data source

· By pressing the "OK" button, the system will display the alias "borey" to the database, which can be used when accessing the borey.mdb file (Figure 9). It should be noted that you can specify an alias to other DBMS in the same way.

Figure 9 - ODBC Data Source Administrator. Dialogue for creating a new data source

2.2 Basic knowledge of the C ++ language (wikipedia)

· C ++ is a compiled statically typed general-purpose programming language.

Supports the following programming paradigms:

Procedural programming,

Object Oriented Programming,

Generalized programming.

Provides:

Modularity,

Separate compilation,

Exception handling,

Data abstraction,

Declaring types (classes) of objects,

Inline functions,

Virtual functions. ·

The standard library includes commonly used containers and algorithms. C ++ combines the properties of both high-level and low-level languages. Compared to its predecessor, the C language, most attention is paid to support for object-oriented and generic programming. The C ++ syntax is inherited from the C language.



The last C ++ language standard, called "C ++ 11", was adopted in 2011. It included significant additions to the core of the language and an extension of the standard library. ·

Open Database Connectivity (ODBC) is the protocol used to connect the database Microsoft data Access to an external data source such as Microsoft SQL Server. This article provides an overview of ODBC data sources and how to create and connect to them using Microsoft Access. The steps you need to take depend on the databases and ODBC drivers you are using.

In this article

About ODBC Data Sources

A data source is a source that contains the data and connection information required to access that data. The data source can be SQL Server, Oracle RDBMS, spreadsheet, or text file. Connection information can include server location, database name, login ID, password, and various ODBC driver parameters that describe how to connect to the data source. This information can be obtained from the administrator of the database to which you want to connect.

In the ODBC architecture, applications (such as Access) connect to the ODBC Driver Manager, which in turn uses a specific ODBC driver (such as Microsoft SQL ODBC) to connect to the data source. Access uses ODBC data sources to connect to external data sources that do not have built-in drivers.

To connect to such a data source, follow these steps.

    Install the appropriate ODBC driver on the data source computer.

    Determine the data source name (DSN) using the program ODBC Data Source Administrator to save the connection information to the registry Microsoft Windows or a DSN file, or by using a connection string in Visual Basic code to pass the connection information directly to the ODBC Driver Manager.

Machine data sources

Machine data sources store connection information in Windows registry on the specific computer... Such data sources can only be used on the computer on which they are defined. There are two types of machine data sources: user and system. Custom data sources are available and visible only to the current user. System data sources can be used by all users of the computer. They are displayed for all of these users and system services. Machine data sources are especially useful when you need to provide additional protection because only logged-on users can view the machine data source. In addition, such a source cannot be remotely copied to another computer.

File data sources

File data sources (also called DSN files) store connection information in text files rather than the Windows registry, and is generally more flexible to use than machine data sources. For example, a file data source can be copied to any computer with a suitable ODBC driver to ensure that the application has accurate and consistent connection information across all computers in use. In addition, you can put the file data source on a separate server, share it across multiple computers on your network, and easily manage centralized connection information.

Some file data sources cannot be shared. Such sources are located on a separate computer and point to a machine data source. They can be used to access existing machine data sources from file data sources.

Connection strings

You can define a formatted string with connection information in the module. The connection string passes the connection information directly to the ODBC Driver Manager. This helps to simplify the application by eliminating the need for an administrator or user to create a DSN before using the database.

For more information on ODBC, see the MSDN ODBC Programmer's Reference.

Adding an ODBC Data Source

Install the correct ODBC driver for the data source you want to connect to before proceeding.

Note: To add or configure an ODBC data source, you must be a member of the Administrators group on the local computer.

For getting additional information about individual parameters press the button reference in the ODBC dialog box.

The bottom line: you need to connect to the database created in the "MS Access" DBMS via "ODBC" in your own application on "Delphi 7".

First, go to the section "Control Panel - Administrative Tools - Data Sources (ODBC)". Add a new data source.

Fig. 1. ODBC Data Source Administrator

Then we select "Driver do Microsoft Access".


Fig. 2. Creating a new data source

Then, in the window "Installing ODBC driver ..." set the name, description and select the path to the database, for example, "Bus station. mdb».

Fig. 3. Installing ODBC driver for MS Access

After that, go to the initial window "Data source administrator ..." and see that the "Bus station" has been added to the source.

Fig. 4. Initial window "Data source administrator ..."

Then we launch the Delphi 7 application, place the components on the form: ADOConnection, ADOTable, DataSource, DBGrid... Configuring components for ODBC connection.

First, we click on the component “ ADOConnection 1 "and set up the connection string, select" Microsoft OLE DB Provider for ODBC ". Click the "Next" button and go to the "Connection" tab.

Fig. 5. Setting up the connection string in "Delphi 7"

On the “Connection” tab, select the data source “Bus station” and check the connection by clicking on the “Check connection” button.

Component

Setting, value

ADOConnection1

LoginPrompt= False

ADOTable1

Connection = ADOConnection1

TableName= Days of movement

DataSource1

DataSet= ADOTable1

DBGrid1

DataSource= DataSource1

Now, if you set the property "Active = True" for the component " ADOTable 1 ", then the table set in the property TableName"Will be displayed on the component" DBGrid one".

Fig. 7. Table "Days of movement" in our application

Thus, we have connected to the "Bus Station" database via "ODBC", which means "Open Data B ase Connectivity".