|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ADOX add bool fieldAccess 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_FieldType), _ TableFields(intFileSetup).Prop_FieldLength) Else NewAddingColumn.Name = TableFields(intFileSetup).Prop_FieldName NewAddingColumn.Type = ReturnFieldType(TableFields(intFileSetup).Prop_FieldType) 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(NewAddingColumn) 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 On Fri, 6 Oct 2006 21:50:18 -0400, "Miro" <miron***@golden.net> wrote: ¤ 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/default.asp?url=/library/en-us/dnacc2k/html/acintsql.asp Paul ~~~~ Microsoft MVP (Visual Basic) 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 Show quoteHide quote "Paul Clement" <UseAdddressAtEndofMess***@swspectrum.com> wrote in message news:m44li214nj0p7vmjmnud2ma8nvcr4f27hq@4ax.com... > On Fri, 6 Oct 2006 21:50:18 -0400, "Miro" <miron***@golden.net> wrote: > > ¤ 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/default.asp?url=/library/en-us/dnacc2k/html/acintsql.asp > > > Paul > ~~~~ > Microsoft MVP (Visual Basic)
Read legacy vb5 files with variant declare in vb.net
Running an Access macro from a VB.NETprogram need help on optional arg Overlapping controls How to determen the object ? WEB combobox won't fire event Redrawing on GDI+ clicking on a DataGridView's DataSource property throws exception in designer Set Focus to textbox on tab control NullReferenceException with shared members |
|||||||||||||||||||||||