472,146 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

ADOX add bool field

Something weird I have run into when trying to add a boolean field to an
Access table by code.
-Just wondering if anyone else has run into this. ( vb.net 2005 express )

If I add any other field other than boolean the "command" version of adding
a field works great.
But if I try to add a boolean field, I get an exception error when its
trying to be added, so instead I have to use the function meathod.
-Code is below.

so basically I have to use Columns.Append( blablalblba
instead of the other way.

-All works...but just seemed to be a funny solution and I did tried it by
fluke and waisted a lot of my time trying to figure out why I couldnt add a
logical field.

So at least it will same some other person still trying to use adox. :)

Cheers

Miro


? TableFields(17)
{Simply_Teaching.FileLayout}
Prop_DBName: "MyDBName"
Prop_FieldLength: 1
Prop_FieldName: "BoolTest"
Prop_FieldType: "Logical"
Prop_TableName: "TableName"
Prop_VersionNo: "1.00"
Prop_KeyIndexField: False

======================
Dim NewAddingColumn As New ADOX.Column()

If TableFields(intFileSetup).Prop_FieldType =
"Logical" Then
ADOXTable(TableintFileSetup).Columns.Append( _
TableFields(intFileSetup).Prop_FieldName, _
ReturnFieldType(TableFields(intFileSetup).Prop_Fie ldType),
_
TableFields(intFileSetup).Prop_FieldLength)

Else
NewAddingColumn.Name =
TableFields(intFileSetup).Prop_FieldName
NewAddingColumn.Type =
ReturnFieldType(TableFields(intFileSetup).Prop_Fie ldType)

If TableFields(intFileSetup).Prop_FieldType <>
"Date" And _
TableFields(intFileSetup).Prop_FieldType <>
"Memo" Then

NewAddingColumn.DefinedSize =
TableFields(intFileSetup).Prop_FieldLength
End If

If TableFields(intFileSetup).Prop_KeyIndexField
= False Then
NewAddingColumn.Attributes =
ADOX.ColumnAttributesEnum.adColNullable
Else
NewAddingColumn.Attributes =
ADOX.ColumnAttributesEnum.adColFixed
End If

'Append the Column to the table.
ADOXTable(TableintFileSetup).Columns.Append(NewAdd ingColumn)
End If

=======================

Private Function ReturnFieldType(ByVal FieldType As String) As
ADOX.DataTypeEnum
Dim DataType As ADOX.DataTypeEnum

If FieldType = "String" Then
DataType = ADOX.DataTypeEnum.adVarWChar
ElseIf FieldType = "Date" Then
'DataType = ADOX.DataTypeEnum.adDBDate 'Throws out an error
DataType = ADOX.DataTypeEnum.adDate
ElseIf FieldType = "Logical" Or FieldType = "Boolean" Then
'datatype = adox.DataTypeEnum.
DataType = ADOX.DataTypeEnum.adBoolean
ElseIf FieldType = "Memo" Then
DataType = ADOX.DataTypeEnum.adLongVarWChar
End If

Return DataType
End Function
Oct 7 '06 #1
3 3461
On Fri, 6 Oct 2006 21:50:18 -0400, "Miro" <mi******@golden.netwrote:

¤ Something weird I have run into when trying to add a boolean field to an
¤ Access table by code.
¤ -Just wondering if anyone else has run into this. ( vb.net 2005 express )
¤
¤ If I add any other field other than boolean the "command" version of adding
¤ a field works great.
¤ But if I try to add a boolean field, I get an exception error when its
¤ trying to be added, so instead I have to use the function meathod.
¤ -Code is below.
¤
¤ so basically I have to use Columns.Append( blablalblba
¤ instead of the other way.
¤
¤ -All works...but just seemed to be a funny solution and I did tried it by
¤ fluke and waisted a lot of my time trying to figure out why I couldnt add a
¤ logical field.
¤
¤ So at least it will same some other person still trying to use adox. :)

You could probably avoid some of these issues by using Jet SQL.

http://msdn.microsoft.com/library/de...l/acintsql.asp
Paul
~~~~
Microsoft MVP (Visual Basic)
Oct 9 '06 #2
Thanks,

I saved the link but I am currently in the process of "learning" vb.net
So the adox for now has served its purpose. Now im onto forms and objects
and then
after, the "binded" ( i think thats what you call it ) objects on forms.
Creating a dummy app is the place to make these mystakes. :-)
If I were to do it again, I think I will try to go the Jet SQL way.

Thanks again,

Miro
"Paul Clement" <Us***********************@swspectrum.comwrote in message
news:m4********************************@4ax.com...
On Fri, 6 Oct 2006 21:50:18 -0400, "Miro" <mi******@golden.netwrote:

¤ Something weird I have run into when trying to add a boolean field to an
¤ Access table by code.
¤ -Just wondering if anyone else has run into this. ( vb.net 2005
express )
¤
¤ If I add any other field other than boolean the "command" version of
adding
¤ a field works great.
¤ But if I try to add a boolean field, I get an exception error when its
¤ trying to be added, so instead I have to use the function meathod.
¤ -Code is below.
¤
¤ so basically I have to use Columns.Append( blablalblba
¤ instead of the other way.
¤
¤ -All works...but just seemed to be a funny solution and I did tried it
by
¤ fluke and waisted a lot of my time trying to figure out why I couldnt
add a
¤ logical field.
¤
¤ So at least it will same some other person still trying to use adox. :)

You could probably avoid some of these issues by using Jet SQL.

http://msdn.microsoft.com/library/de...l/acintsql.asp
Paul
~~~~
Microsoft MVP (Visual Basic)

Oct 11 '06 #3
JetSQL?

fucking dipshits dont use jet for anything.. telling newbies to run
out and learn 2 different dialects of SQL is the most ridiculous thing
i've ever heard.

Dont use MDB for anything
Spit on anyone that still uses it.

-Aaron

Paul Clement wrote:
On Fri, 6 Oct 2006 21:50:18 -0400, "Miro" <mi******@golden.netwrote:

¤ Something weird I have run into when trying to add a boolean field toan
¤ Access table by code.
¤ -Just wondering if anyone else has run into this. ( vb.net 2005 express )
¤
¤ If I add any other field other than boolean the "command" version of adding
¤ a field works great.
¤ But if I try to add a boolean field, I get an exception error when its
¤ trying to be added, so instead I have to use the function meathod.
¤ -Code is below.
¤
¤ so basically I have to use Columns.Append( blablalblba
¤ instead of the other way.
¤
¤ -All works...but just seemed to be a funny solution and I did tried it by
¤ fluke and waisted a lot of my time trying to figure out why I couldntadd a
¤ logical field.
¤
¤ So at least it will same some other person still trying to use adox. :)

You could probably avoid some of these issues by using Jet SQL.

http://msdn.microsoft.com/library/de...l/acintsql.asp
Paul
~~~~
Microsoft MVP (Visual Basic)
Oct 11 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Developer98115 | last post: by
1 post views Thread by Randy | last post: by
5 posts views Thread by Wayne Wengert | last post: by
8 posts views Thread by T Clancey | last post: by
2 posts views Thread by mouac01 | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.