Allow Zero Lenght Property in Access 
Author Message
 Allow Zero Lenght Property in Access

Is there a way to set the Allow Zero Length Property of an Access Field
using the ODBC API.  My entire app is written in ODBC API except the
function below.  We have had users crash when this function runs.  Although
it never crashes on any of our test machines.

Every time the code GetFieldInfo is run, I see a "First-chance exception in
c2.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception."  However, the
code continues to run and the AllowZeroLenght property is set correctly.

Is there a way to set this propert in the SQL CREATE TABLE?

I am using VC++ 6.0 SP3.

Thanks,
-Pat

************************
void set_allow_zero_length(CString db_path, char* table_name)
{
    int flag_open_was_ok = 0;
    CDaoDatabase db;
    int i = 0;
    try
    {
        db.Open(db_path, TRUE);
        flag_open_was_ok = 1;
    }
    catch ( CDaoException* pdao )
    {
        CString temp = pdao->m_pErrorInfo->m_strDescription;
        flag_open_was_ok = 0;
    }

    if ( flag_open_was_ok == 1 )
    {
        CDaoTableDef tb(&db);

        tb.Open(table_name);

        short count = tb.GetFieldCount();

        for ( i = count-1 ; i>-1; i-- )
        {
            // GET THE FIELD INTO
            CDaoFieldInfo fd;
            try
            {
                tb.GetFieldInfo( i, fd, AFX_DAO_ALL_INFO);
            }
            catch ( CDaoException* pdao )
            {
                CString temp = pdao->m_pErrorInfo->m_strDescription;
            }

            // SET THE ALLOW ZERO LENGTH TO TRUE
            fd.m_bAllowZeroLength = TRUE;

            // DELETE THE FIELD
            try
            {
                tb.DeleteField(i);
            }
            catch ( CDaoException* pdao )
            {
                CString temp = pdao->m_pErrorInfo->m_strDescription;
            }

            try
            {
                tb.CreateField(fd);
            }
            catch ( CDaoException* pdao )
            {
                CString temp = pdao->m_pErrorInfo->m_strDescription;
            }
        }
        tb.Close();

        db.Close();
    }

Quote:
}



Sat, 31 Aug 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Allow Zero Length Text Fields In Access

2. Zero Length Arrays Allowed in C Standard?

3. Frameset Blinking, won't allow property changes

4. file access allowing multiple instances

5. Help: Need to find a library that will allow me to access COM2:

6. Current ATL DLL allowing ASP to access

7. NT 4.0 allows memory access violations!!!

8. zero/negative zero??

9. comparing +zero and -zero

10. How to access Custom Database Properties of a Access 97 database programmatically

11. Property access vs. field access

12. Alternate to FileInfo.Lenght?

 

 
Powered by phpBB® Forum Software