C Builder

First released in 1997, Borland C Builder is a Rapid Application Design environment that uses the C language, but includes the same GUI IDE as Borland Delphi. It includes the Delphi compiler and can make use of Delphi code in C projects. Borland C Builder replaces Borland C product. This product was targeted at business and enterprise customers. Current supported versions are sold. I am using C Builder 10.2.3 (Rad Studio 10.2.3) I am trying to convert a TRectF to a Variant. But it seems not to be working: 1st Solution: using TValue::From(rect).AsVariant or AsType.

-->

In earlier versions of ADO.NET, compile-time checking of connection strings with concatenated string values did not occur, so that at run time, an incorrect keyword generated an ArgumentException. Each of the .NET Framework data providers supported different syntax for connection string keywords, which made constructing valid connection strings difficult if done manually. To address this problem, ADO.NET 2.0 introduced new connection string builders for each .NET Framework data provider. Each data provider includes a strongly typed connection string builder class that inherits from DbConnectionStringBuilder. The following table lists the .NET Framework data providers and their associated connection string builder classes.

ProviderConnectionStringBuilder class
System.Data.SqlClientSystem.Data.SqlClient.SqlConnectionStringBuilder
System.Data.OleDbSystem.Data.OleDb.OleDbConnectionStringBuilder
System.Data.OdbcSystem.Data.Odbc.OdbcConnectionStringBuilder
System.Data.OracleClientSystem.Data.OracleClient.OracleConnectionStringBuilder

Connection String Injection Attacks

A connection string injection attack can occur when dynamic string concatenation is used to build connection strings that are based on user input. If the string is not validated and malicious text or characters not escaped, an attacker can potentially access sensitive data or other resources on the server. For example, an attacker could mount an attack by supplying a semicolon and appending an additional value. The connection string is parsed by using a 'last one wins' algorithm, and the hostile input is substituted for a legitimate value.

The connection string builder classes are designed to eliminate guesswork and protect against syntax errors and security vulnerabilities. They provide methods and properties corresponding to the known key/value pairs permitted by each data provider. Each class maintains a fixed collection of synonyms and can translate from a synonym to the corresponding well-known key name. Checks are performed for valid key/value pairs and an invalid pair throws an exception. In addition, injected values are handled in a safe manner.

Builder

The following example demonstrates how the SqlConnectionStringBuilder handles an inserted extra value for the Initial Catalog setting.

C Builder

The output shows that the SqlConnectionStringBuilder handled this correctly by escaping the extra value in double quotation marks instead of appending it to the connection string as a new key/value pair.

Building Connection Strings from Configuration Files

If certain elements of a connection string are known beforehand, they can be stored in a configuration file and retrieved at run time to construct a complete connection string. For example, the name of the database might be known in advance, but not the name of the server. Or you might want a user to supply a name and password at run time without being able to inject other values into the connection string.

C++ Builder Embarcadero

One of the overloaded constructors for a connection string builder takes a String as an argument, which enables you to supply a partial connection string that can then be completed from user input. The partial connection string can be stored in a configuration file and retrieved at run time.

Note

The System.Configuration namespace allows programmatic access to configuration files that use the WebConfigurationManager for Web applications and the ConfigurationManager for Windows applications. For more information about working with connection strings and configuration files, see Connection Strings and Configuration Files.

C Builder Vs Visual C++

Example

C Builders

This example demonstrates retrieving a partial connection string from a configuration file and completing it by setting the DataSource, UserID, and Password properties of the SqlConnectionStringBuilder. The configuration file is defined as follows.

C Builders

Note

You must set a reference to the System.Configuration.dll in your project for the code to run.

See also