473,903 Members | 4,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Teachin g.FileLayout}
Prop_DBName: "MyDBName"
Prop_FieldLengt h: 1
Prop_FieldName: "BoolTest"
Prop_FieldType: "Logical"
Prop_TableName: "TableName"
Prop_VersionNo: "1.00"
Prop_KeyIndexFi eld: False

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

If TableFields(int FileSetup).Prop _FieldType =
"Logical" Then
ADOXTable(Table intFileSetup).C olumns.Append( _
TableFields(int FileSetup).Prop _FieldName, _
ReturnFieldType (TableFields(in tFileSetup).Pro p_FieldType),
_
TableFields(int FileSetup).Prop _FieldLength)

Else
NewAddingColumn .Name =
TableFields(int FileSetup).Prop _FieldName
NewAddingColumn .Type =
ReturnFieldType (TableFields(in tFileSetup).Pro p_FieldType)

If TableFields(int FileSetup).Prop _FieldType <>
"Date" And _
TableFields(int FileSetup).Prop _FieldType <>
"Memo" Then

NewAddingColumn .DefinedSize =
TableFields(int FileSetup).Prop _FieldLength
End If

If TableFields(int FileSetup).Prop _KeyIndexField
= False Then
NewAddingColumn .Attributes =
ADOX.ColumnAttr ibutesEnum.adCo lNullable
Else
NewAddingColumn .Attributes =
ADOX.ColumnAttr ibutesEnum.adCo lFixed
End If

'Append the Column to the table.
ADOXTable(Table intFileSetup).C olumns.Append(N ewAddingColumn)
End If

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

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

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

Return DataType
End Function
Oct 7 '06 #1
3 3579
On Fri, 6 Oct 2006 21:50:18 -0400, "Miro" <mi******@golde n.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************ ***********@sws pectrum.comwrot e in message
news:m4******** *************** *********@4ax.c om...
On Fri, 6 Oct 2006 21:50:18 -0400, "Miro" <mi******@golde n.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******@golde n.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
5575
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 Interop reference to the ADOX COM component from my C# project. I am able to open the SqlConnection successfully but it fails with an exception when I try to set the ..ActiveConnection property of the ADOX database catalog object. Another strange...
1
3078
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 = new ADOX.CatalogClass(); cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + path + ";" + "Jet OLEDB:Engine Type=5");
5
2088
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 this? ==================== code ================= Sub CreateADOUnitsTable(ByVal sTablename As String) Dim oDB As ADOX.Catalog Dim oUnits As ADOX.Table
3
1725
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 vb.net application(code is below) by using ADOX. Now my problem is i want delete one record from master table, that deleted record automatically deleted from child tables. so, i want the code how to establish relation ships between the tables and...
2
1126
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 the contact_id field in the master table as a primary key and in child tables as foreign key and cascading to delete property. how to maintain relationships with in the database at the creation of the JET Database file only. Thanks for your...
1
11610
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: Description (Column property?), Decimal Places, Caption, Default value, Required indicator, Format, etc.... TIA,
8
2740
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 of examples which are basically the same, but none of them work! I can create my tables and fields without any problems at all, but I want to
6
3707
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 ADOX.Catalog Dim tbl As ADOX.Table Dim col As ADOX.Column Dim strSql As String 'Delete all records.
2
3394
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 Test() Dim cat As ADOX.Catalog Dim tbl As ADOX.Table Dim col As ADOX.Column Set cat = New Catalog
0
10003
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9692
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8055
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5897
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6099
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4312
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3327
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.