Note that there are some explanatory texts on larger screens.

plurals
  1. POVB6 execution with database is different when stepping through vs running
    text
    copied!<p>I've come across a weird scenario with the following code in a vb6 app:</p> <pre><code>Private database As dao.Database Set database = openDaoDatabase([some valid database location], False) createDBField database, "Table", "FirstRow", dao.dbInteger, 0, "0" Public Sub createDBField(targetDB As dao.Database, strTable As String, strField As String, dbType As dao.DataTypeEnum, Size As Integer, strDefValue As String) Dim td As dao.TableDef Dim fld As dao.field Set td = targetDB.TableDefs(strTable) Set fld = td.CreateField(strField, dbType, 0) If dbType = dao.DataTypeEnum.dbText Or dbType = dao.DataTypeEnum.dbMemo Then fld.AllowZeroLength = True If strDefValue &lt;&gt; "" Then fld.DefaultValue = strDefValue td.Fields.Append fld Set td = Nothing Set fld = Nothing End Sub </code></pre> <p>When I step through, everything works and the new field is added to the database. However, when I simply run the application, the database becomes corrupted due to 'inconsistency'. I added some error handling and now get the error: "Unrecognized database format: [path]". After searching the Microsoft database, I found a solution: <a href="http://support.microsoft.com/kb/238401" rel="nofollow noreferrer">http://support.microsoft.com/kb/238401</a>. I'm using the Microsoft.Jet.OLEDB.4.0 provider, have SP6 installed and have a reference to the Microsoft DAO 3.6 Object Library, but it's still not working!</p> <p>Any thoughts?</p> <p>Update: td.Fields.Append fld is the culprit. After removing all silent error handling, I was able to catch an error: "Run-time error 3343 Unrecognized Database Format". For some reason, I can just step over it though.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload