Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 1st, 2008, 12:33 PM   #1
kartik07
Newbie
 
Join Date: Jan 2008
Posts: 2
Rep Power: 0 kartik07 is on a distinguished road
How to store XML data in ACCESS DB using VB6

Hi ,
I am new to VB6 and doing a proj in VB6
I need to extract data from an XML file and store it in a
database table(MS ACCESS).Lets say Tablename=XYZ
I used the code in module modmain but I am getting an error
saying "could not find installable ISAM".
The MS ACCESS Table contains following fields:
1.Machine ID
2.Fault id
3.Date of Occurence
4.Time of Occurence

consider the XML File
<MACHINE>
<ID>
100
<FAULTID>F001</FAULTID>
<DOO>06.42.19</DOO>
<TOO>06.02.1997</TOO>
</ID>
<ID>
100
<FAULTID>F002</FAULTID>
<DOO>05.12.19</DOO>
<TOO>06.02.1997</TOO>
</ID>
</MACHINE>



AL the above values need to be stored in ACCESS table.I used XML4 here.
Public g_ConDB As ADODB.Connection
Public g_domXML As DOMDocument40
Public g_rsFaults As Recordset


Public Sub Main()
  ConnectDB
  LoadXML
  OpenRS
  AddFaultRecords
  CloseRS
  CloseDB
End Sub

Public Sub ConnectDB()

  Set g_ConDB = New Connection
  g_ConDB.Open "provider = Microsoft.Jet.OLEDB.4.0; datasource = F:\xml2test\db1.mdb"
End Sub

Public Sub LoadXML()
  Set g_domXML = New DOMDocument40
  g_domXML.Load "F:\xml2test\MS1.xml"
End Sub

Public Sub OpenRS()
  Set g_rsFaults = New Recordset
  g_rsFaults.LockType = adlockpesimistic
  Set g_rsFaults.ActiveConnection = g_ConDB
  g_rsFaults.Open "Select * from xyz"

End Sub

Public Sub AddFaultRecords()
  Dim ndFault As IXMLDOMNode
  Dim lngMachineID As Long
  Dim FaultID As String
  Dim dtDate As Date
  Dim strTime As String
  For Each ndFault In g_domXML.selectNodes("/MACHINE")
    lngMachineID = Val(ndFault.selectSingleNode("ID").Text)
    FaultID = ndFault.selectSingleNode("FAULTID").Text
    dtDate = CDate(ndFault.selectSingleNode("DOO").Text)
    strTime = ndFault.selectSingleNode("TOO").Text

    g_rsFaults.findfirst "[machine id]=" & lngMachineID & " and [Fault id]='" & FaultID & "'"
    If g_rsFaults.EOF Then
       g_rsFaults.AddNew
      g_rsFaults("Machine ID") = lngMachineID
      g_rsFaults("Fault ID") = FaultID
    End If

    g_rsFaults("Date Of Occurence") = dtDate
    g_rsFaults("Time of Occurence") = strTime
    g_rsFaults.Update
  Next ndFault


End Sub
Private Sub CloseRS()
   g_rsFaults.Close
End Sub
Private Sub CloseDB()
   g_ConDB.Close
End Sub


Can someone rectify the error & if possible can explain the meaning of this code,not the whole thing but atleast the gist.
I need it urgently.
kartik07 is offline   Reply With Quote
Old Jan 1st, 2008, 12:35 PM   #2
kartik07
Newbie
 
Join Date: Jan 2008
Posts: 2
Rep Power: 0 kartik07 is on a distinguished road
Re: How to store XML data in ACCESS DB using VB6

I used start mode from submain & used Microsoft Active DAta Objects (2.6) & msxml4
kartik07 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wierd Access DB -> Data Grid Issue Kilo C# 3 Aug 27th, 2007 9:42 AM
How can I access the data in a HBITMAP directly? Mage_From_Antares C++ 0 Mar 5th, 2006 9:12 PM
Recommended Practice for returning data from function Arla C# 1 Aug 16th, 2005 12:21 PM
help with sockets, having a client recieve data as well as send. cypherkronis Python 7 Jul 1st, 2005 5:59 PM
Access COBOL external data in Assembler packerm Other Programming Languages 0 May 24th, 2005 5:03 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:04 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC