PRB: Uninitialized String Variables, Empty String Values, Jet Provider, and Errors Occurred
ID: Q228935
|
The information in this article applies to:
-
ActiveX Data Objects (ADO), versions 2.0, 2.01, 2.1
-
Microsoft OLE DB Provider for Jet, versions 3.51, 4.0
-
Microsoft Data Access Components versions 2.0, 2.1
SYMPTOMS
If a WITH statement is used to store an empty string value to one field and an uninitialized string to the very next field, an error will occur when using the Microsoft OLE DB Provider for Jet 3.51 or 4.00.
'Errors Occurred'
RESOLUTION
The best resolution at this time is to make sure all variables are properly initialized.
MORE INFORMATIONSteps to Reproduce Behavior
NOTE: Change the DBPath variable to point to an .mdb file.
- Start Visual Basic 6.0.
- Create a Standard EXE Project.
- Set the following Project Reference:
Microsoft ActiveX Data Objects Library
- Paste the following code into the default form:
Dim CN As ADODB.Connection
Dim RS As ADODB.Recordset
Dim strSQL As String
Dim DBPath As String
Dim emptystring As String 'If this is initialized it does not error.
'emptystring = ""
Set CN = New ADODB.Connection
Set RS = New ADODB.Recordset
DBPath = "D:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB"
On Error Resume Next 'for table drop & creation
With CN
.ConnectionString = "Data Source=" & DBPath
.Provider = "Microsoft.Jet.OLEDB.3.51"
.Open
.Execute "drop table testit"
.Execute "Create table TestIt (Fld1 Text(10), Fld2 Integer, Fld3 Text(10))"
End With
On Error GoTo 0 'for table drop & creation
strSQL = "select * from Testit"
RS.Open strSQL, CN, adOpenKeyset, adLockOptimistic
RS.AddNew
With RS
!Fld1 = ""
!Fld3 = emptystring '"Errors Occurred."
End With
- Run the form.
© Microsoft Corporation 1999, All Rights Reserved. Contributions by Matthew Hofacker, Microsoft Corporation
Additional query words:
Keywords : kbADO kbDatabase kbJET kbOLEDB kbGrpVBDB
Version : WINDOWS:2.0,2.01,2.1,3.51,4.0
Platform : WINDOWS
Issue type : kbprb
|