Visual Basic Q&A

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘field’

BUG: Error “Row Cannot Be Located for Updating” If You Change Numeric Field in ADODC Recordset

Symptoms
If an ActiveX Data Objects data control (ADODC) is bound to a Microsoft Access table that specifies a default value for the numeric field, when you take the following actions:Add a new record to the ADO recordset, which the ADODC exposes, without entering a value for that numeric field.Update the recordset.Type a value into the numeric field (either directly into the Recordset field or into the corresponding DataGrid cell) in that same newly-added record.Update the recordset again.the following run-time error is raised with error number -2147217864 (80040e38) or 6153:

Row cannot be located for updating. Some values may have changed since it was last read.If a DataGrid control is bound to the ADODC, the same error message usually appears a second time without an error number in a dialog box that is entitled “Microsoft DataGrid Control.”
Resolution
To resolve this problem, remove the default value that is specified for the numeric field in the Access database table.
Alternately, you can run an UPDATE statement on a separate ADO Connection object to update the numeric field in the newly-added record directly in the database and then refresh the ADODC.

PRB: Error When You Access an Array Field of a .NET Structure from COM

Symptoms
When you access an Array field of a structure that is defined in .NET from inside a COM DLL, you may receive the following error message:

“An unhandled exception of type ‘System.ArgumentException’ occurred in ProjectName”
Additional information: Wrong number of arguments or invalid property assignment.
Resolution
Because of the late-bound method that is used in this case, the Visual Basic 6.0 runtime cannot get the type information for the Array field that you are attempting to access.

PRB: Error Setting Field Format Property of Access Tables

Symptoms
From Visual Basic, when trying to specify a field Format property of anAccess table (for example, field type DateTime) from blank to “Long Date”format, the following error occurs:

Run-time error ‘3421′:
Data type conversion error.
Resolution
The property data type constant should always be “dbText.” If other datatype constants, such as dbDate or dbNumeric are specified, you willencounter the error described above.

PRB: Calculated Field Contents Cannot be Modified by ADO

Symptoms
Trying to modify the contents of a calculated field within an ActiveX Data Objects (ADO) recordset, generates the following error:

Runtime error ‘-2147217887(80040e21)’ errors occurred.
Resolution
Each calculated field in an ADO recordset contains the following attributes:
adFldUnknownUpdatable = False
-and- adFldUpdatable = False This indicates that the field cannot be modified.

PRB: 32-bit BASIC Does Not Convert UNICODE/ANSI in Binary Field

Symptoms
When using a binary field to store text in a Microsoft Jet 2.5 or earlierdatabase, 32-bit applications cannot read text written by 16-bitapplications and vice versa.
Resolution
Unlike Memo fields, the 32-bit programs do no automatic ANSI/UNICODEconversion on binary fields.

How To Use ADOX to Create an OLE Object Field in an Access Database

Symptoms
This article describes how to use ActiveX Data Objects Extensibility (ADOX) to create an OLE Object field in a Microsoft Access Database (.mdb file). You must use the adLongVarBinary constant to create the field. You do not have to specify a field size in the field definition.
Resolution
Step-by-Step ExampleCreate a new Standard EXE project in Visual Basic. Form1 is created by default.From the Project menu, click References. From the list of available components, click Microsoft ADO Ext. 2.1 for DDL and Security.Add a CommandButton control to Form1.Paste the following code onto the Declarations section of Form1:

Private Sub Command2_Click()Set cat = New ADOX.CatalogSet tbl = New ADOX.Tablecat.ActiveConnection = _”Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\nwind2.mdb;”tbl.Name = “OleObjTable”tbl.Columns.Append “Column1″, adIntegertbl.Columns.Append “Column2″, adIntegertbl.Columns.Append “Column3″, adVarWChar, 50′ Please note adLongVarBinary = 205tbl.Columns.Append “MyOleObject”, adLongVarBinarycat.Tables.Append tblEnd Sub Modify the cat.ActiveConnection assignment to point to a valid Microsoft Access Database file.Run the project, and click Command1. Notice that a table named OleObjTable is created in the database. When you view the table in Design Mode, the Column3 field definition is displayed as OLE Object.