473,385 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 3536
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Developer98115 | last post by:
I need help getting schema information from an existing SQL Server database. My thought was that you could use ADOX via InterOp. Has anyone done this successfully and how? I have created a...
1
by: Randy | last post by:
Hello, I'm not sure if this is the correct place to post this, but I've got a C# app in which I've added a reference to the ADOX (Interop.ADOX) library and I'm using... ADOX.CatalogClass cat =...
5
by: Wayne Wengert | last post by:
I am getting an error that "object no longer valid" at the point indicated in the code below - I am trying to build a table in an Access 2000 database using ADOX. Any thoughts on what might cause...
3
by: gaffar | last post by:
Sir, Using ADOX I am developing an application in vb.net and the backend database is ms-access. i have created ms-access databse and tables and assigned primary keys to the tables through the...
2
by: gaffar | last post by:
Hello Sir, i have done the funtionality to create a JET Database by Using ADOX. now my problem is to establish relationship between the tables. i have one master table and 3 child tables basing on...
1
by: Hexman | last post by:
I'm creating a new Access table using ADOX. I can add columns and indexes, but I'm baffled on how to change field properties. Can someone give me a hand? Want to change properties such as:...
8
by: T Clancey | last post by:
Hi. I have an application that needs to update a database, as I'm using vb net and an access database I have to do this using ADOX. I don't think there is another way. I have found all sorts...
6
by: Jacopo | last post by:
Hi to everyone. I am having a problem running the following code downloaded from the tips of Allen Browne: Function DeleteAllAndResetAutoNum(strTable As String) As Boolean Dim cat As New...
2
by: mouac01 | last post by:
I can't set the field description property with the code below. I get the error "Item cannot be found in the collection corresponding to the requested name or ordinal". Any ideas. TIA... Sub...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.