2 simple ADO questions which really bug me.

2 simple ADO questions which really bug me.

Post by Raymond G. Henderso » Wed, 24 May 2000 04:00:00



Alex,

First problem:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\new.mdb" will create an
Access 2000 database.
Try "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=c:\new.mdb"

Second problem:
I think you'll have to do it with SQL.

Raymond

 
 
 

2 simple ADO questions which really bug me.

Post by alexradu.. » Thu, 25 May 2000 04:00:00


Hi. Although I'm pretty good with DAO, I'm only a starter with ADO. So
here are my two questions:

1. How do I create a db from code ? MSDN shows this:

Sub CreateDatabase()

    Dim cat As New ADOX.Catalog
    cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\new.mdb"
End Sub

Looks to work fine, but... When I try to open the db with Access 97, it
says "Unrecognized Database Format". The size is ok, though: 64kb.

2. How do I set the fields' properties after having created a table by
code ? MSDN: "For a Field object, the Attributes property is read-only,
and its value can be the sum of any one or more of these
FieldAttribu*um values"... I need to make fields to accept nulls
(attribute adFldIsNullable). I'm using this code to create the table:

Private Function DB_Table_Create() As Boolean

    Dim tblTableDef As New Table
    Dim catCatalog As New ADOX.Catalog
    Dim intCounter As Integer

    On Error GoTo DB_Table_CreateError

    ' Open the Catalog:
    catCatalog.ActiveConnection = m_dbConnection

    tblTableDef.Name = "Download"
    tblTableDef.Columns.Append "DownloadTime", adDate
    For intCounter = 1 To 68
        tblTableDef.Columns.Append "ID" & CStr(intCounter), adDouble
    Next intCounter
    catCatalog.Tables.Append tblTableDef

    DB_Table_Create = True

DB_Table_CreateExit:
    Set tblTableDef = Nothing
    Set catCatalog = Nothing
    Exit Function

DB_Table_CreateError:
    MsgBox Error & ", " & Err,
vbInformation, "modClient.DB_Table_Create"
    DB_Table_Create = False
    Resume DB_Table_CreateExit
End Function

Since I have 69 columns (fields), an ALTER TABLE SQL would be
impractical, and the SQL String will be cery long.

Thank you,
Alex

Sent via Deja.com http://www.veryComputer.com/
Before you buy.

 
 
 

2 simple ADO questions which really bug me.

Post by Will Fair » Thu, 25 May 2000 04:00:00


Raymond is right about the first part, as for the second part,
why don't you set the column attributes right after appending?

ex.
tblTableDef.Columns.Append "DownloadTime", adDate
tblTableDef.Columns("DownloadTime").Attributes = adColNullable


Quote:> Hi. Although I'm pretty good with DAO, I'm only a starter with ADO. So
> here are my two questions:

> 1. How do I create a db from code ? MSDN shows this:

> Sub CreateDatabase()

>     Dim cat As New ADOX.Catalog
>     cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\new.mdb"
> End Sub

> Looks to work fine, but... When I try to open the db with Access 97, it
> says "Unrecognized Database Format". The size is ok, though: 64kb.

> 2. How do I set the fields' properties after having created a table by
> code ? MSDN: "For a Field object, the Attributes property is read-only,
> and its value can be the sum of any one or more of these
> FieldAttribu*um values"... I need to make fields to accept nulls
> (attribute adFldIsNullable). I'm using this code to create the table:

> Private Function DB_Table_Create() As Boolean

>     Dim tblTableDef As New Table
>     Dim catCatalog As New ADOX.Catalog
>     Dim intCounter As Integer

>     On Error GoTo DB_Table_CreateError

>     ' Open the Catalog:
>     catCatalog.ActiveConnection = m_dbConnection

>     tblTableDef.Name = "Download"
>     tblTableDef.Columns.Append "DownloadTime", adDate
>     For intCounter = 1 To 68
>         tblTableDef.Columns.Append "ID" & CStr(intCounter), adDouble
>     Next intCounter
>     catCatalog.Tables.Append tblTableDef

>     DB_Table_Create = True

> DB_Table_CreateExit:
>     Set tblTableDef = Nothing
>     Set catCatalog = Nothing
>     Exit Function

> DB_Table_CreateError:
>     MsgBox Error & ", " & Err,
> vbInformation, "modClient.DB_Table_Create"
>     DB_Table_Create = False
>     Resume DB_Table_CreateExit
> End Function

> Since I have 69 columns (fields), an ALTER TABLE SQL would be
> impractical, and the SQL String will be cery long.

> Thank you,
> Alex

> Sent via Deja.com http://www.veryComputer.com/
> Before you buy.

 
 
 

2 simple ADO questions which really bug me.

Post by steve_han.. » Tue, 13 Jun 2000 04:00:00


The code below should successfully create an Access97 database.

 cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=c:\new.mdb;Jet OLEDB:Engine Type=4"

Regards,
Steve



> Raymond is right about the first part, as for the second part,
> why don't you set the column attributes right after appending?

> ex.
> tblTableDef.Columns.Append "DownloadTime", adDate
> tblTableDef.Columns("DownloadTime").Attributes = adColNullable



> > Hi. Although I'm pretty good with DAO, I'm only a starter with ADO.
So
> > here are my two questions:

> > 1. How do I create a db from code ? MSDN shows this:

> > Sub CreateDatabase()

> >     Dim cat As New ADOX.Catalog
> >     cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\new.mdb"
> > End Sub

> > Looks to work fine, but... When I try to open the db with Access
97, it
> > says "Unrecognized Database Format". The size is ok, though: 64kb.

> > 2. How do I set the fields' properties after having created a table
by
> > code ? MSDN: "For a Field object, the Attributes property is read-
only,
> > and its value can be the sum of any one or more of these
> > FieldAttribu*um values"... I need to make fields to accept nulls
> > (attribute adFldIsNullable). I'm using this code to create the
table:

> > Private Function DB_Table_Create() As Boolean

> >     Dim tblTableDef As New Table
> >     Dim catCatalog As New ADOX.Catalog
> >     Dim intCounter As Integer

> >     On Error GoTo DB_Table_CreateError

> >     ' Open the Catalog:
> >     catCatalog.ActiveConnection = m_dbConnection

> >     tblTableDef.Name = "Download"
> >     tblTableDef.Columns.Append "DownloadTime", adDate
> >     For intCounter = 1 To 68
> >         tblTableDef.Columns.Append "ID" & CStr(intCounter), adDouble
> >     Next intCounter
> >     catCatalog.Tables.Append tblTableDef

> >     DB_Table_Create = True

> > DB_Table_CreateExit:
> >     Set tblTableDef = Nothing
> >     Set catCatalog = Nothing
> >     Exit Function

> > DB_Table_CreateError:
> >     MsgBox Error & ", " & Err,
> > vbInformation, "modClient.DB_Table_Create"
> >     DB_Table_Create = False
> >     Resume DB_Table_CreateExit
> > End Function

> > Since I have 69 columns (fields), an ALTER TABLE SQL would be
> > impractical, and the SQL String will be cery long.

> > Thank you,
> > Alex

> > Sent via Deja.com http://www.veryComputer.com/
> > Before you buy.

Sent via Deja.com http://www.veryComputer.com/
Before you buy.
 
 
 

1. A simple question, really simple

How can I make a case sensitive comparsion in the WHERE clause? I
can't found the answer from the on-line help.



----------------------------------------------------------------------------
           Personal homepage : http://www.hk.super.net/~leolau

2. Can't get exe to launch

3. really simple but it's bugging me 2

4. Where is Microsoft English Query Domain Editor?

5. really simple but it's bugging me.....

6. Oracle Webserver

7. Simple simple ADO question

8. WIN 2000 vs NT4 Transformation Services

9. Really simple question

10. Really Simple VFP Question (But Not For Me)

11. A really simple jdbc question - please, please help

12. Really simple DB question...

13. NewEra and graphes, help - simple question, really into