Qyoto
4.0.5
Qyoto is a C# language binding for Qt
|
The QSqlField class manipulates the fields in SQL database tables and views. More...
Public Types | |
enum | RequiredStatus { Optional = 0, Required = 1, Unknown = -1 } |
More... | |
Public Member Functions | |
override bool | Equals (object o) |
override int | GetHashCode () |
QSqlField (QSqlField other) | |
| |
QSqlField (string fieldName="", QVariant.Type type=QVariant.Type.Invalid) | |
| |
virtual void | CreateProxy () |
new void | Clear () |
| |
new bool | IsAutoValue () |
| |
new bool | IsGenerated () |
| |
new bool | IsNull () |
| |
new bool | IsReadOnly () |
| |
new bool | IsValid () |
| |
new void | SetAutoValue (bool autoVal) |
| |
new void | SetGenerated (bool gen) |
| |
new void | SetReadOnly (bool readOnly) |
| |
new void | SetRequired (bool required) |
| |
new void | SetSqlType (int type) |
new int | TypeID () |
new void | Dispose () |
Static Public Member Functions | |
static bool | operator!= (QSqlField arg1, QSqlField arg2) |
| |
static bool | operator== (QSqlField arg1, QSqlField arg2) |
| |
Protected Member Functions | |
QSqlField (System.Type dummy) | |
Protected Attributes | |
SmokeInvocation | interceptor |
Properties | |
new object | DefaultValue [get, set] |
| |
new int | Length [get, set] |
| |
new string | Name [get, set] |
| |
new int | Precision [get, set] |
| |
new QSqlField.RequiredStatus | requiredStatus [get, set] |
| |
new QVariant.Type | Type [get, set] |
| |
new object | Value [get, set] |
| |
virtual System.IntPtr | SmokeObject [get, set] |
The QSqlField class manipulates the fields in SQL database tables and views.
QSqlField represents the characteristics of a single column in a database table or view, such as the data type and column name. A field also contains the value of the database column, which can be viewed or changed.
Field data values are stored as QVariants. Using an incompatible type is not permitted. For example:
QSqlField field("age", QVariant::Int);
field.setValue(QPixmap()); // WRONG
However, the field will attempt to cast certain data types to the field data type where possible:
QSqlField field("age", QVariant::Int);
field.setValue(QString("123")); // casts QString to int
QSqlField objects are rarely created explicitly in application code. They are usually accessed indirectly through QSqlRecords that already contain a list of fields. For example:
QSqlQuery query;
...
QSqlRecord record = query.record();
QSqlField field = record.field("country");
A QSqlField object can provide some meta-data about the field, for example, its name(), variant type(), length(), precision(), defaultValue(), typeID(), and its requiredStatus(), isGenerated() and isReadOnly(). The field's data can be checked to see if it isNull(), and its value() retrieved. When editing the data can be set with setValue() or set to NULL with clear().
See also QSqlRecord.
Specifies whether the field is required or optional.
See also requiredStatus().
|
protected |
QtSql.QSqlField.QSqlField | ( | QSqlField | other | ) |
Constructs a copy of other.
QtSql.QSqlField.QSqlField | ( | string | fieldName = "" , |
QVariant.Type | type = QVariant.Type.Invalid |
||
) |
Constructs an empty field called fieldName of variant type type.
See also setRequiredStatus(), setLength(), setPrecision(), setDefaultValue(), setGenerated(), and setReadOnly().
new void QtSql.QSqlField.Clear | ( | ) |
Clears the value of the field and sets it to NULL. If the field is read-only, nothing happens.
See also setValue(), isReadOnly(), and requiredStatus().
|
virtual |
new void QtSql.QSqlField.Dispose | ( | ) |
override bool QtSql.QSqlField.Equals | ( | object | o | ) |
override int QtSql.QSqlField.GetHashCode | ( | ) |
new bool QtSql.QSqlField.IsAutoValue | ( | ) |
Returns true if the value is auto-generated by the database, for example auto-increment primary key values.
See also setAutoValue().
new bool QtSql.QSqlField.IsGenerated | ( | ) |
Returns true if the field is generated; otherwise returns false.
See also setGenerated(), type(), requiredStatus(), length(), precision(), and defaultValue().
new bool QtSql.QSqlField.IsNull | ( | ) |
Returns true if the field's value is NULL; otherwise returns false.
See also value().
new bool QtSql.QSqlField.IsReadOnly | ( | ) |
Returns true if the field's value is read-only; otherwise returns false.
See also setReadOnly(), type(), requiredStatus(), length(), precision(), defaultValue(), and isGenerated().
new bool QtSql.QSqlField.IsValid | ( | ) |
Returns true if the field's variant type is valid; otherwise returns false.
Returns true if the field is unequal to other; otherwise returns false.
Returns true if the field is equal to other; otherwise returns false.
new void QtSql.QSqlField.SetAutoValue | ( | bool | autoVal | ) |
Marks the field as an auto-generated value if autoVal is true.
See also isAutoValue().
new void QtSql.QSqlField.SetGenerated | ( | bool | gen | ) |
Sets the generated state. If gen is false, no SQL will be generated for this field; otherwise, Qt classes such as QSqlQueryModel and QSqlTableModel will generate SQL for this field.
See also isGenerated(), setType(), setRequiredStatus(), setLength(), setPrecision(), setDefaultValue(), and setReadOnly().
new void QtSql.QSqlField.SetReadOnly | ( | bool | readOnly | ) |
Sets the read only flag of the field's value to readOnly. A read-only field cannot have its value set with setValue() and cannot be cleared to NULL with clear().
See also isReadOnly().
new void QtSql.QSqlField.SetRequired | ( | bool | required | ) |
Sets the required status of this field to Required if required is true; otherwise sets it to Optional.
See also setRequiredStatus() and requiredStatus().
new void QtSql.QSqlField.SetSqlType | ( | int | type | ) |
new int QtSql.QSqlField.TypeID | ( | ) |
|
protected |
|
getset |
Returns the field's default value (which may be NULL).
Sets the default value used for this field to value.
|
getset |
Returns the field's length.
If the returned value is negative, it means that the information is not available from the database.
Sets the field's length to fieldLength. For strings this is the maximum number of characters the string can hold; the meaning varies for other types.
|
getset |
Returns the name of the field.
Sets the name of the field to name.
|
getset |
Returns the field's precision; this is only meaningful for numeric types.
If the returned value is negative, it means that the information is not available from the database.
Sets the field's precision. This only affects numeric fields.
|
getset |
Returns true if this is a required field; otherwise returns false. An INSERT will fail if a required field does not have a value.
Sets the required status of this field to required.
|
getset |
|
getset |
Returns the field's type as stored in the database. Note that the actual value might have a different type, Numerical values that are too large to store in a long int or double are usually stored as strings to prevent precision loss.
Set's the field's variant type to type.
|
getset |
Returns the value of the field as a QVariant.
Use isNull() to check if the field's value is NULL.
Sets the value of the field to value. If the field is read-only (isReadOnly() returns true), nothing happens.
If the data type of value differs from the field's current data type, an attempt is made to cast it to the proper type. This preserves the data type of the field in the case of assignment, e.g. a QString to an integer data type.
To set the value to NULL, use clear().