Hi all
I have a table in a database, one of the columns is TEXT NOT NULL
UNIQUE. If I want to find out which column has been designated unique,
how can I do it?
I can get the DataType of each column by testing the value of
objDs1.Tables(0).Columns(numColumnNumber).DataType.ToString where objDs1
is a DataSet and numColumnNumber increments from 0 to n.
I found objDs1.Tables(0).Columns(numColumnNumber).Unique but this
returns False for a column I know I set as TEXT NOT NULL UNIQUE.
[I often use the structure of a table to recreate the table as new from
scratch, or to clone it into a different table, eg. I have a table
called 'Customers', I want to have a table called 'Enquirers' with
exactly the same structure. At the moment, the clone does not have the
UNIQUE format for the column in Customers which does have it, although
everything else is present in the new table.]
Thanks in advance
Jonathan
For VB'ers, this is what I use to interrogate the table to be cloned:
For Each objRow1 In objDs1.Tables(0).Rows
If numRowNo = 0 Then
'Gather field names and types:
numColNo = 1 + 2 'RecNo is already in.
Do Until numColNo - 2 >
objDs1.Tables(0).Columns.Count - 1
Select Case
objDs1.Tables(0).Columns(numColNo - 2).DataType.ToString
Case "System.String"
strThisFieldType = "TEXT COLLATE
NOCASE DEFAULT ('')"
'This is the bit that is wrong:
If
objDs1.Tables(0).Columns(numColNo - 2).Unique = True Then
MsgBox("Have found a UNIQUE
column type!")
End If
Case "System.Int32"
strThisFieldType = "INTEGER NOT
NULL DEFAULT (0)"
Case "etc."
End Select
gstrCreateTableSQLString =
gstrCreateTableSQLString & objDs1.Tables(0).Columns(numColNo -
2).ColumnName & " " & strThisFieldType & ","
numColNo = numColNo + 1
Loop
End If
'Etc. etc.
Next
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users