ImportXML method

  • Thread starter Thread starter Matteo Gabella
  • Start date Start date
M

Matteo Gabella

Hi all, i'm using ImportXML method to create and populate an Access
database but, even if the XML file contains the complete table
definitions (like primary keys, etc...) the resulting database has no
primary key!
Is it a know bug? Any suggestion?
Thanks MG
 
MG,

See KB 283854 at the below link.

http://support.microsoft.com/default.aspx?scid=kb;en-
us;283854&Product=acc2002

This article contains links that may offer some
explanation. One of the links states that Access 2002
does not support importing schemas. I believe this means
that you'll need to manually set the primary key.

I don't know whether XML support has been improved in
Access 2003.
 
i did it that way:
i loaded the XML file in an access instance (created with vb.net) with
the importXML feature, than i rebuild all the indexes, retriving them
from a dataset, filled with the same xml...

here's the code

'-----------------------------

For Each t As DataTable In dsXMLdataset.Tables

pbProgress.Value += 1

Select Case t.PrimaryKey.Length

Case 1
oAccApp.DoCmd.RunSQL("CREATE INDEX PK_" +
t.PrimaryKey(0).Caption + " ON " + t.TableName + " (" +
t.PrimaryKey(0).Caption + " ASC) WITH PRIMARY")
System.Threading.Thread.Sleep(500)
Application.DoEvents()

Case Is > 1
Dim sFie As String
For Each k As System.Data.DataColumn In t.PrimaryKey()
Dim sKeyField As String = k.Caption
sFie = sFie & sKeyField & " ASC, "
Next
sFie = Microsoft.VisualBasic.Left(sFie, Len(sFie) - 6)
oAccApp.DoCmd.RunSQL("CREATE INDEX PK_" & Str(nTotK).Trim
& " ON " + t.TableName + " (" & sFie & ") WITH PRIMARY")
nTotK += 1
System.Threading.Thread.Sleep(500)
Application.DoEvents()

End Select

Next

'-----------------------------
 
Back
Top