DAO type problems 
Author Message
 DAO type problems

I've been struggling with this one for weeks, so here goes:

In DAO 3.6, the following doesn't work
    Dim tdf as DAO.TableDef
    Dim idx as DAO.Index
    Dim fld as DAO.Field
    tdf = dbf.Tables("MyTable")
    idx = tdf.CreateIndex("NewIndex")
    fld = idx.CreateField("KeyField")
    idx.Fields.Append(fld)  '<------- This line is the problem

The DAO.Index.Fields collection no longer exposes any methods because of the
dropping of support for defaulting. Unfortunately, there also doesn't seem
to be any way of getting access to the path by full qualification (because
it's not documented anywhere. The following also doesn't work:

    Dim flds as DAO.Fields
    flds = idx.Fields '<-------- conversion error. The type is a COM object
    flds.Append(fld) '<----- This would work if I could get flds set
                                'properly

Does anyone have a clue as to what I can do about this? I can't go to ODBC
directly, because MS Access doesn't support ON DELETE CASCADE in its CREATE
TABLE statement.

Thanks,

Randy



Mon, 07 Feb 2005 22:09:03 GMT  
 DAO type problems
First off Randy,

This question would be better addressed in a MS Access newsgroup.  DAO is
not part of the DotNet archictecture.

As for your problem you don't seem to be assinging any values to the field
before appending it to the table.

For more help I suggest reposting to a MS Access newsgroup.

Google has a good one at their site:    comp.databases.ms-access

Michael



Quote:
> I've been struggling with this one for weeks, so here goes:

> In DAO 3.6, the following doesn't work
>     Dim tdf as DAO.TableDef
>     Dim idx as DAO.Index
>     Dim fld as DAO.Field
>     tdf = dbf.Tables("MyTable")
>     idx = tdf.CreateIndex("NewIndex")
>     fld = idx.CreateField("KeyField")
>     idx.Fields.Append(fld)  '<------- This line is the problem

> The DAO.Index.Fields collection no longer exposes any methods because of
the
> dropping of support for defaulting. Unfortunately, there also doesn't seem
> to be any way of getting access to the path by full qualification (because
> it's not documented anywhere. The following also doesn't work:

>     Dim flds as DAO.Fields
>     flds = idx.Fields '<-------- conversion error. The type is a COM
object
>     flds.Append(fld) '<----- This would work if I could get flds set
>                                 'properly

> Does anyone have a clue as to what I can do about this? I can't go to ODBC
> directly, because MS Access doesn't support ON DELETE CASCADE in its
CREATE
> TABLE statement.

> Thanks,

> Randy



Mon, 07 Feb 2005 22:19:53 GMT  
 DAO type problems
MW,

I've tried that NG without success. The problem is that I've been told by MS
that I *have to* use DAO. The problem is not that I haven't assigned values
(I snipped that, sorry). The sub-attributes of ".Fields" are no longer
accessible. I'm looking for a way to "fully qualify" the attributes, per the
conversion instructions in MSDN, but there don't appear to be any. Forgive
the frustration, but I've been struggling with this for weeks, trying
various approachs, including ADO, ADODB, ADO.NET, ODBC, but because of
limitations in each, I'm stuck with DAO, and that doesn't work either.

I consider this a VB issue, because defaulting has been removed. The
question is, again, how can I fully qualify it.

Thanks for trying anyway.


Quote:
> First off Randy,

> This question would be better addressed in a MS Access newsgroup.  DAO is
> not part of the DotNet archictecture.

> As for your problem you don't seem to be assinging any values to the field
> before appending it to the table.

> For more help I suggest reposting to a MS Access newsgroup.

> Google has a good one at their site:    comp.databases.ms-access

> Michael


> message


- Show quoted text -

Quote:
> > I've been struggling with this one for weeks, so here goes:

> > In DAO 3.6, the following doesn't work
> >     Dim tdf as DAO.TableDef
> >     Dim idx as DAO.Index
> >     Dim fld as DAO.Field
> >     tdf = dbf.Tables("MyTable")
> >     idx = tdf.CreateIndex("NewIndex")
> >     fld = idx.CreateField("KeyField")
> >     idx.Fields.Append(fld)  '<------- This line is the problem

> > The DAO.Index.Fields collection no longer exposes any methods because of
> the
> > dropping of support for defaulting. Unfortunately, there also doesn't
seem
> > to be any way of getting access to the path by full qualification
(because
> > it's not documented anywhere. The following also doesn't work:

> >     Dim flds as DAO.Fields
> >     flds = idx.Fields '<-------- conversion error. The type is a COM
> object
> >     flds.Append(fld) '<----- This would work if I could get flds set
> >                                 'properly

> > Does anyone have a clue as to what I can do about this? I can't go to
ODBC
> > directly, because MS Access doesn't support ON DELETE CASCADE in its
> CREATE
> > TABLE statement.

> > Thanks,

> > Randy



Mon, 07 Feb 2005 22:29:14 GMT  
 DAO type problems
Randy,

What I would try is to write COM DLL in VB6 to wrap all this functionality.
Then just use this DLL from .NET to make it work.

I may be wrong, but that should work.



Quote:
> I've been struggling with this one for weeks, so here goes:

> In DAO 3.6, the following doesn't work
>     Dim tdf as DAO.TableDef
>     Dim idx as DAO.Index
>     Dim fld as DAO.Field
>     tdf = dbf.Tables("MyTable")
>     idx = tdf.CreateIndex("NewIndex")
>     fld = idx.CreateField("KeyField")
>     idx.Fields.Append(fld)  '<------- This line is the problem

> The DAO.Index.Fields collection no longer exposes any methods because of
the
> dropping of support for defaulting. Unfortunately, there also doesn't seem
> to be any way of getting access to the path by full qualification (because
> it's not documented anywhere. The following also doesn't work:

>     Dim flds as DAO.Fields
>     flds = idx.Fields '<-------- conversion error. The type is a COM
object
>     flds.Append(fld) '<----- This would work if I could get flds set
>                                 'properly

> Does anyone have a clue as to what I can do about this? I can't go to ODBC
> directly, because MS Access doesn't support ON DELETE CASCADE in its
CREATE
> TABLE statement.

> Thanks,

> Randy



Mon, 07 Feb 2005 23:37:10 GMT  
 DAO type problems


I've been struggling with this one for weeks, so here goes:

In DAO 3.6, the following doesn't work
    Dim tdf as DAO.TableDef
    Dim idx as DAO.Index
    Dim fld as DAO.Field
    tdf = dbf.Tables("MyTable")
    idx = tdf.CreateIndex("NewIndex")
    fld = idx.CreateField("KeyField")
    idx.Fields.Append(fld)  '<------- This line is the problem

The DAO.Index.Fields collection no longer exposes any methods because of the
dropping of support for defaulting. Unfortunately, there also doesn't seem
to be any way of getting access to the path by full qualification (because
it's not documented anywhere. The following also doesn't work:

    Dim flds as DAO.Fields
    flds = idx.Fields '<-------- conversion error. The type is a COM object

Have you tried using the CType function:

        flds = CType(idx.Fields, DAO.Fields)

BTW, Option Strict On will catch these types of errors.


Microsoft MVP (Visual Basic)



Tue, 08 Feb 2005 01:33:34 GMT  
 DAO type problems

Quote:
> On Thu, 22 Aug 2002 14:09:03 GMT, "Randy at Home"


Quote:

> I've been struggling with this one for weeks, so here goes:
>
> In DAO 3.6, the following doesn't work
>     Dim tdf as DAO.TableDef
>     Dim idx as DAO.Index
>     Dim fld as DAO.Field
>     tdf = dbf.Tables("MyTable")
>     idx = tdf.CreateIndex("NewIndex")
>     fld = idx.CreateField("KeyField")
>     idx.Fields.Append(fld)  '<------- This line is the problem
>
> The DAO.Index.Fields collection no longer exposes any methods because of
the
> dropping of support for defaulting. Unfortunately, there also doesn't
seem
> to be any way of getting access to the path by full qualification
(because
> it's not documented anywhere. The following also doesn't work:
>
>     Dim flds as DAO.Fields
>     flds = idx.Fields '<-------- conversion error. The type is a COM
object

> Have you tried using the CType function:

>         flds = CType(idx.Fields, DAO.Fields)

This yields the same run-time result I was getting doing an uncast
conversion: Specified cast is invalid. It appears that idx.Fields isn't
usable, which is what I was getting also under C#.


Tue, 08 Feb 2005 02:20:58 GMT  
 DAO type problems
Try idx.Fields.Append(fld) without the brackets
i.e.
===============
idx.Fields.Append fld
===============
This was a common area of fustration with DAO, when to use brackets and when
not to.  This is not as much of an issue with DotNet.

Michael



Quote:
> MW,

> I've tried that NG without success. The problem is that I've been told by
MS
> that I *have to* use DAO. The problem is not that I haven't assigned
values
> (I snipped that, sorry). The sub-attributes of ".Fields" are no longer
> accessible. I'm looking for a way to "fully qualify" the attributes, per
the
> conversion instructions in MSDN, but there don't appear to be any. Forgive
> the frustration, but I've been struggling with this for weeks, trying
> various approachs, including ADO, ADODB, ADO.NET, ODBC, but because of
> limitations in each, I'm stuck with DAO, and that doesn't work either.

> I consider this a VB issue, because defaulting has been removed. The
> question is, again, how can I fully qualify it.

> Thanks for trying anyway.



> > First off Randy,

> > This question would be better addressed in a MS Access newsgroup.  DAO
is
> > not part of the DotNet archictecture.

> > As for your problem you don't seem to be assinging any values to the
field
> > before appending it to the table.

> > For more help I suggest reposting to a MS Access newsgroup.

> > Google has a good one at their site:    comp.databases.ms-access

> > Michael


> > message

> > > I've been struggling with this one for weeks, so here goes:

> > > In DAO 3.6, the following doesn't work
> > >     Dim tdf as DAO.TableDef
> > >     Dim idx as DAO.Index
> > >     Dim fld as DAO.Field
> > >     tdf = dbf.Tables("MyTable")
> > >     idx = tdf.CreateIndex("NewIndex")
> > >     fld = idx.CreateField("KeyField")
> > >     idx.Fields.Append(fld)  '<------- This line is the problem

> > > The DAO.Index.Fields collection no longer exposes any methods because
of
> > the
> > > dropping of support for defaulting. Unfortunately, there also doesn't
> seem
> > > to be any way of getting access to the path by full qualification
> (because
> > > it's not documented anywhere. The following also doesn't work:

> > >     Dim flds as DAO.Fields
> > >     flds = idx.Fields '<-------- conversion error. The type is a COM
> > object
> > >     flds.Append(fld) '<----- This would work if I could get flds set
> > >                                 'properly

> > > Does anyone have a clue as to what I can do about this? I can't go to
> ODBC
> > > directly, because MS Access doesn't support ON DELETE CASCADE in its
> > CREATE
> > > TABLE statement.

> > > Thanks,

> > > Randy



Tue, 08 Feb 2005 02:23:08 GMT  
 DAO type problems
I just don't believe it. When I put the brackets in explicitly, it doesn't
work. When I don't, VS.Net adds the brackets and it works. The text result
is identical, but one works and the other doesn't. I'm convinced that VS.Net
is non-deterministic and has a little genie inside making seemingly random
decisions <only slightly joking>. I tried idx.Fields.Append(fld) about two
weeks ago and it didn't work.


Quote:
> Try idx.Fields.Append(fld) without the brackets
> i.e.
> ===============
> idx.Fields.Append fld
> ===============
> This was a common area of fustration with DAO, when to use brackets and
when
> not to.  This is not as much of an issue with DotNet.

> Michael


> message


Quote:
> > MW,

> > I've tried that NG without success. The problem is that I've been told
by
> MS
> > that I *have to* use DAO. The problem is not that I haven't assigned
> values
> > (I snipped that, sorry). The sub-attributes of ".Fields" are no longer
> > accessible. I'm looking for a way to "fully qualify" the attributes, per
> the
> > conversion instructions in MSDN, but there don't appear to be any.
Forgive
> > the frustration, but I've been struggling with this for weeks, trying
> > various approachs, including ADO, ADODB, ADO.NET, ODBC, but because of
> > limitations in each, I'm stuck with DAO, and that doesn't work either.

> > I consider this a VB issue, because defaulting has been removed. The
> > question is, again, how can I fully qualify it.

> > Thanks for trying anyway.



> > > First off Randy,

> > > This question would be better addressed in a MS Access newsgroup.  DAO
> is
> > > not part of the DotNet archictecture.

> > > As for your problem you don't seem to be assinging any values to the
> field
> > > before appending it to the table.

> > > For more help I suggest reposting to a MS Access newsgroup.

> > > Google has a good one at their site:    comp.databases.ms-access

> > > Michael


> > > message

> > > > I've been struggling with this one for weeks, so here goes:

> > > > In DAO 3.6, the following doesn't work
> > > >     Dim tdf as DAO.TableDef
> > > >     Dim idx as DAO.Index
> > > >     Dim fld as DAO.Field
> > > >     tdf = dbf.Tables("MyTable")
> > > >     idx = tdf.CreateIndex("NewIndex")
> > > >     fld = idx.CreateField("KeyField")
> > > >     idx.Fields.Append(fld)  '<------- This line is the problem

> > > > The DAO.Index.Fields collection no longer exposes any methods
because
> of
> > > the
> > > > dropping of support for defaulting. Unfortunately, there also
doesn't
> > seem
> > > > to be any way of getting access to the path by full qualification
> > (because
> > > > it's not documented anywhere. The following also doesn't work:

> > > >     Dim flds as DAO.Fields
> > > >     flds = idx.Fields '<-------- conversion error. The type is a COM
> > > object
> > > >     flds.Append(fld) '<----- This would work if I could get flds set
> > > >                                 'properly

> > > > Does anyone have a clue as to what I can do about this? I can't go
to
> > ODBC
> > > > directly, because MS Access doesn't support ON DELETE CASCADE in its
> > > CREATE
> > > > TABLE statement.

> > > > Thanks,

> > > > Randy



Tue, 08 Feb 2005 02:41:43 GMT  
 DAO type problems

Quote:
>I've tried that NG without success. The problem is that I've been told by MS
>that I *have to* use DAO.

They lied to you. The easiest and most efficient way is to use SQL
DML, which you can execute directly from an OleDbCommand object. The
following statement creates a primary key.

CREATE UNIQUE INDEX PrimaryKey ON Table1 (Col1) WITH PRIMARY

This will create a non-unique index:

CREATE INDEX MyIndex ON Table1 (Col1)

Multiple columns can be specified in a comma-delimited list inside the
parens.

-- Mary
MCW Technologies
http://www.mcwtech.com



Tue, 08 Feb 2005 23:05:16 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. MBF vs TYPE...END TYPE problems

2. MBF VS TYPE...END TYPE problems

3. Data Type Problem accessing Btrieve (MBF) data type

4. Data Type Problem accessing Btrieve (MBF) data type

5. Data Type Problem accessing Btrieve (MBF) data type

6. problem of converting C's union type to VB's a data type

7. problem of converting C's union type to VB's a data type

8. Type mismatch on openrecordset statement in DAO

9. Type Mismatch error using DAO

10. DAO code "Type Mismatch" error

11. DAO causes type mismatch on recordset defining

12. Access 2.0, OLE Data Types, and DAO

 

 
Powered by phpBB® Forum Software