Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create a table w/ ADOX error

Status
Not open for further replies.

TRYP

Programmer
Jun 20, 2000
136
0
0
US
Hi all,

im going insane trying to debug this on...

im getting an error on the line
Cat.Tables.Append(CType(objTable, Object))

error is invalid type

any help is appreciated
thanks
tryp


Private Sub createTable(ByVal dBasePath As String)

Dim Cn As ADODB.Connection
Dim Cat As ADOX.Catalog
Dim objTable As New ADOX.Table

Dim colMemo As New ADOX.Column
Dim colID As New ADOX.Column
Dim colDate As New ADOX.Column


Cn = New ADODB.Connection()

Cat = New ADOX.Catalog()

'objTable = New ADOX.Table()

''Open the connection
Cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & dBasePath & ";")

'Open the Catalog
Cat.ActiveConnection = Cn

'Create the table
objTable.Name = "Notes"


With colID

.ParentCatalog = Cat
.Name = "NoteID"
.Type = ADOX.DataTypeEnum.adInteger
.Properties("AutoIncrement").Value = True
.Properties("Nullable").Value = False

End With

With colMemo
.ParentCatalog = Cat
.Name = "Note"
.Type = ADOX.DataTypeEnum.adLongVarWChar
.Properties.Item("Nullable").Value = False
End With

With colDate
.ParentCatalog = Cat
.Name = "CreateDate"
.Type = ADOX.DataTypeEnum.adDBTimeStamp
.Properties.Item("Nullable").Value = False
End With

objTable.let_ParentCatalog(Cat)

With objTable.Columns

.Append(colID)
.Append(colMemo)
.Append(colDate)

End With

'Append the newly created table to the Tables Collection


Cat.Tables.Append(CType(objTable, Object))

' clean up objects
objTable = Nothing

Cat = Nothing

Cn.Close()
Cn = Nothing

End Sub

 
Why are you changing the ADOX.Table to an Object?

CType(objTable, Object)

Try just appending the table object to the tables collection, with no conversion:

Cat.Tables.Append(objTable)

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
...jebenson

i added the ctype because at first i had it the way you suggested and it gave the same complaint

...rick

database and tables can be created w/ ado.net?? didnt think that was possible....

-tryp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top