473,698 Members | 2,153 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cycling thru Access table fields in DotNet and enumerating column definitions.

I am having trouble finding the AutoNumber field of my database with this
code. The code is used to replicate a specific table, reproducing all
columns including indexes and Primary Keys (there is a good reason to do it
this way), but I can not detect the columns which are Primary Keys as I
cycle thru the column collection

Can someone pls help me?
ADOCatODBC = New ADOX.Catalog
ADOCatODBC.let_ ActiveConnectio n(CnnODBC)

FieldNameColl = New Collection
Call ListViewMakeRow (lvLog, Block_def.NoCha nge, "GetFieldNames" ,
"Collecting field objects into collection object")
tblSourceTable = ADOCatODBC.Tabl es(FromTable) ' Make a link to
the tblSourceTable table.
Call ListViewMakeRow (lvLog, Block_def.NoCha nge, "GetFieldNames" , "",
"Table " & FromTable & " opened")

For Each tblSourceTable_ col In tblSourceTable. Columns
Call ListViewMakeRow (lvLog, Block_def.NoCha nge, "GetFieldNames" ,
"", "", "Field '" & tblSourceTable_ col.Name & "' found. Type is '" &
tblSourceTable_ col.Type)
'
' Read the properties of the original fields and place these in
a collection.
'
On Error Resume Next
FieldNameProper ties = New clsADOX_Collect ionProperties
With FieldNameProper ties
.ColName = tblSourceTable_ col.Name ' Record the
field name.
'
' For some reason, TimeDate fields come across as
adDBTimeStamp types and Currency fields come across as adNumeric.
' The only field types you can write to the temporary table
are:
'
' Type Number Data Type
' 2 Number (Integer)
' 3 Number (Long Integer)
' 4 Number (Single)
' 5 Number (Double)
' 6 Currency
' 7 Date/Time
' 11 Yes/No
' 17 Number (Byte)
' 72 Number (Replication ID)
' 128 Binary
' 130 Text
' 202 Text
' 203 Memo
' 204 Binary
' 205 OLE Object
'

' The following types returned need to be converted to new
types as VB.Net doesn't
' recognise them.
Select Case tblSourceTable_ col.Type
Case ADOX.DataTypeEn um.adDBTimeStam p
' Date & Time.
.ColType = ADOX.DataTypeEn um.adDate
Case ADOX.DataTypeEn um.adNumeric
' Currency.
.ColType = ADOX.DataTypeEn um.adCurrency
Case Else
' The rest ....
.ColType = tblSourceTable_ col.Type
End Select
.Precision = tblSourceTable_ col.Precision
'
' Depending on the field type, there are certain default
settings which need to be imposed
' if they are not specified on the original field.
' Note that some properties are not defined and by reading
them you may generate an error
' condition. Also, if properties are not defined, defaults
need to be assigned instead.
'
Select Case tblSourceTable_ col.Type
Case DataTypeEnum.ad GUID Or
ADOX.ColumnAttr ibutesEnum.adCo lFixed
.AutoIncrement = tblSourceTable_ col.Properties( "Jet
OLEDB:AutoGener ate").Value
Case DataTypeEnum.ad Boolean
'skip
Case Else
.AutoIncrement =
tblSourceTable_ col.Properties( "AutoIncrement" ).Value
If Not .AutoIncrement Then
If tblSourceTable_ col.DefinedSize = 0 Then
.FieldSize = 50
Else
.FieldSize =
IIf(tblSourceTa ble_col.Defined Size 65535, 65535,
tblSourceTable_ col.DefinedSize )
End If
If
tblSourceTable_ col.Properties( "Default").Valu e = Nothing Then
.DefaultValue = ""
Else
.DefaultValue =
tblSourceTable_ col.Properties( "Default").Valu e
End If
If tblSourceTable_ col.Properties( "Jet
OLEDB:Allow Zero Length").Value = False Then
.AllowZeroLengt h = False
Else
.AllowZeroLengt h = True
End If
If
tblSourceTable_ col.Properties( "Nullable").Val ue Then
.Required = False
Else
.Required = True
End If
End If
End Select
End With

FieldNameColl.A dd(FieldNamePro perties)

Application.DoE vents()
Next tblSourceTable_ col

VB.Net 2003.

--

|
+-- JDMils
|
Sep 10 '06 #1
0 1600

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2619
by: E. Zorn | last post by:
Hi, i use Access as a frontend via ODBC to an Linux-based postgresql. I have a problem in a form where I use a lot of subforms. In some cases ( i couldn't detect when - but I really try to) the form and Access hangs. The only way to close the form is to close Access via "cross" (upper right corner). If I try then to view once again the form I get the following error message:
13
2911
by: Peter | last post by:
Can anyone tell me how to change the data type of a field in a table created with a make table query? The field is a binary and must be changed to text. alternately does anyone know how to specify the field type when running a make table query? Thanks, Sven
1
9195
by: Andrew Arace | last post by:
I scoured the groups for some hands on code to perform the menial task of exporting table data from an Access 2000 database to Oracle database (in this case, it was oracle 8i but i'm assuming this will work for 9i and even 10g ) No one had what I needed, so I wrote it myself. I Rule. This code isn't going for efficiency, and isn't trying to be dynamic. It doesn't create the table structure in Oracle, that's up to you. (I
1
1105
by: John Jessen | last post by:
Via ODBC I have connected to a MySQL database. I need to extract data into a csv-file, in such a way that there will be one line with order header info, one or more ordrelines, one header, one or more order lines, etc. The content of the "Hedader" and "Line" lines are different. Can this be done in MS-Access? If not I would appreciate advise on what kind of tool that could do this job. John
1
1662
by: Bob Alston | last post by:
Anyone have experience in building Access apps with user definable fields? (Not the kind of fields where you just let the user define the label for a pre set number of predefined fields.) I recently saw an app that uses an MDB database and allows the user to define totally new fields. The app maintains a table of the data fields. When a new field is added, it is actually added to the table in the MDB. He uses multi-column form into...
15
2551
by: philip | last post by:
On a form, I have a datagridview. This datagridview is constructed on a dataset filled by a tableadapter. The table adapter do very well what it must do when filling dataset. Insertions, modifications and deletions functions very well in the dataset. But impossible to transmit modifications in ACCESS database. Impossible to WRITE in database. Here is the code for data transmission from tableadapter to Access database :
4
6404
by: alexandre.brisebois | last post by:
Hi, I am using access 2003, I would like to know if there is an option to reorganize the tables in a maner that is readable, as we can do in sql sever 2000 or 2005. I have been given a database to look a and I am loosing tremendious amounts of time trying to organize it so that I could view it. Regards, Alexandre Brisebois
10
4318
by: Forest14 | last post by:
Hello! Happy Christmas/holidays to you all I have this huge table named "Positions" with more than 160 fields of which the fields are named with non obvious abbreviations. I have another table named "definitions" which has the column name and definition fields. In order to help me all along my forthcoming developments, I would like to use these definitions from table "definitions" into "Positions". Of course i can manually copy each...
3
31569
by: visu | last post by:
Hi , can anyone tell me how to get the complete table schema including constraints, primary key ..etc. through sql Query in Ms access. We can get table information in MS SQL Server by means using sp_help.I want to know the equivalent sql command for ms-access. thanks in advance
0
8674
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...
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8893
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
7723
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
6518
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
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2001
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.