Results 1 to 24 of 24

Thread: database transfer between diff platforms

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47

    database transfer between diff platforms

    hi all....
    ok this is very tricky ...

    i have to make a project in vb.net which will transfer all the data in a MS Access database on a WIN platform to a mySQL database on a Linux platform....

    please ppl this is really urgent n very important..
    thnx in advance
    Last edited by amNewatVB; Mar 11th, 2004 at 03:13 AM.

  2. #2
    Member
    Join Date
    Mar 2004
    Posts
    39
    XML maybe?

    /Nisse

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    i dont have to use XML...just VB.Net.
    please ppl i need to do it urgently

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by amNewatVB
    i dont have to use XML...just VB.Net.
    please ppl i need to do it urgently
    All what you need to do is :
    After getting all data from the database into a dataset , then use
    VB Code:
    1. Yourdataset.WriteXml(path)
    This exports a XML file that should be easily read by SQL Server through the dataset obj with this method :
    VB Code:
    1. Yourdataset.ReadXml(path)

  5. #5

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    will this do on a linux platform...coz thatz where i want to copy the database ???
    also this means i'll have to take one table at a time.....plz can u explain in more detail

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by amNewatVB
    will this do on a linux platform...coz thatz where i want to copy the database ???
    also this means i'll have to take one table at a time.....plz can u explain in more detail
    If I'm not wrong , XML is cross-platforms file . Your database file (mdb) can be exported to XML file . You just keep iteration the dataset obj from the source , if you have more than one table , then add them to the tables collection of the dataset . At the end , use the methods I showed you above .(haven't done tables collection part yet but I've read about it) .

    Or

    You can put each table in separate XML file by changing table name used in the dataset .

  7. #7
    Member
    Join Date
    Mar 2004
    Posts
    39
    XML should be cross platform. And it would surprise me if yhe SQL for linux platform handles XML differently from Windows based SQL.

    /Nisse

  8. #8

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    ok...as of now i've generated the xml and saved it in a text file using the code below.
    Code:
    mydataset.writexml(path)
    in this the path is the text file.

    now how do i transfer it to mysql on linux.

    in the code
    Code:
    mydataset.readxml(path)
    what path shud i give ??? the connection string to mysql database ?? help me here guys

    n will it also work if i have to create that same database ?? i mean can a xml be generated that contains the table structure, so that using some code i can create the table and then insert the data ???
    Last edited by amNewatVB; Mar 12th, 2004 at 01:59 AM.

  9. #9
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by amNewatVB
    ok...as of now i've generated the xml and saved it in a text file using the code below.
    Code:
    mydataset.writexml(path)
    in this the path is the text file.

    now how do i transfer it to mysql on linux.

    in the code
    Code:
    mydataset.readxml(path)
    what path shud i give ??? the connection string to mysql database ?? help me here guys

    n will it also work if i have to create that same database ?? i mean can a xml be generated that contains the table structure, so that using some code i can create the table and then insert the data ???
    mysql connection string

    When you read XML into dataset , then you're able to add /delete records , then write again the XML file .

  10. #10

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    i'm sorry but i didnt get u..
    in the code
    Code:
    mydataset.readxml(path)
    the path is the file where the xml document is saved, right ?
    now to transfer it to the mysql database on linux platform, do i give the same file or do i give the connection string for that database ??
    can u give me the code plz ??
    thnx...n waiting for a response

  11. #11
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by amNewatVB
    i'm sorry but i didnt get u..
    in the code
    Code:
    mydataset.readxml(path)
    the path is the file where the xml document is saved, right ?
    now to transfer it to the mysql database on linux platform, do i give the same file or do i give the connection string for that database ??
    can u give me the code plz ??
    thnx...n waiting for a response

    the path is the file where the xml document is saved, right ?

    Yes .

    Then , again , try loading XML file into dataset using ReadXml () method , then connect to mysql server and update the database there . I've not tried this , so I can't give a working code .

  12. #12

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    ok...will try that
    now as i asked earlier...can i get the table structure the same way ???
    this method will copy the data, right ??? what if i wanna copy the structure n create the table altogether ???

  13. #13
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    ReadXmlSchema() of the dataset will read the structure only .
    ReadXML() read data and structure ofcourse .

    the same applies to :
    write.. write structure only
    writeXML data and structure .

  14. #14

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    with ReadXML....i jget the data and the column headers.....what i want is their datatype and size as well so that i can create a replica of the table elsewhere (mysql database)

  15. #15

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    hey pirate..i'm facing a prob while reading the XML too !!!
    this is what i'm doing

    Code:
    Private Sub btnConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvert.Click
            Try
                myAdapter.Fill(MyDataset1)
                MyDataset1.WriteXml("c:\test.txt")
                MsgBox("Data transferred")
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    End Sub
    here myAdapter is the oledbadapter to an access database.

    Code:
    Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
            Try
                DataSet21.ReadXml("c:\test.txt")
                myAdapter1.Update(DataSet21)
                MsgBox("Read")
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub
    here myAdapter1 is an oledbadapter to another access database (doing it just to see if it works with same kind of database)

    the problem is that the other database is not being filled with the data...what am i doing wrong ??

  16. #16
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    You should export XML file not text file , then load XML not text file .

  17. #17

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    ok now i did
    Code:
    myDataSet1.ReadXML("C:\test.xml")
    and
    Code:
    myDataSet2.WriteXML("C:\test.txt")
    still the same thing..the other database has no records
    Last edited by amNewatVB; Mar 12th, 2004 at 05:52 AM.

  18. #18
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Yes .

  19. #19

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    nothing happens

  20. #20
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    What do you mean the other database ??

  21. #21

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    the database where i want the data to be placed. for now it is another ms access database.

  22. #22
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I've just tried it and both methods works (write xml and load it) . I don't know what the hell is your problme , Is that the only code you have there ?

  23. #23

    Thread Starter
    Member
    Join Date
    Dec 2003
    Location
    Delhi, India
    Posts
    47
    after writing, i've called the update method of the dataadapter

    myAdapter2.Update(dataset)

  24. #24
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I did little demo , this code works for me .
    VB Code:
    1. 'Class level variables
    2. Private DBName As String
    3.     Private dbConnection As OleDbConnection
    4.     Private sqlstring As String = "SELECT * FROM SecurityTab"
    5.    
    6.  
    7.     Private Sub WriteXMLFile()
    8.         Try
    9.             DBName = "c:\db1.mdb"
    10.             dbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBName & ";Persist Security Info=False")            
    11.             Dim ds As New DataSet
    12.             Dim adp As New OleDb.OleDbDataAdapter
    13.  
    14.             dbConnection.Open()
    15.  
    16.             adp.SelectCommand = New OleDbCommand("SELECT * FROM SecurityTab", dbConnection)
    17.             adp.Fill(ds)
    18.             ds.WriteXml("c:\test.xml")
    19.             MessageBox.Show("Finished writing XML File")
    20.  
    21.         Catch ex As Exception
    22.             MessageBox.Show(ex.Message)
    23.         End Try
    24.     End Sub
    25.  
    26.  
    27.  Private Sub ReadXMLFile()
    28.         Try
    29.             Dim ds2 As New DataSet
    30.             Dim adp2 As New OleDb.OleDbDataAdapter(Me.sqlstring, Me.dbConnection)
    31.             Dim builder As New OleDbCommandBuilder(adp2)            
    32.         ds2.ReadXml("c:\test.xml")
    33.             adp2.Update(ds2)
    34.         MessageBox.Show(ds2.Tables(0).Rows(0).Item(0))
    35.  
    36.         Catch ex As Exception
    37.             MessageBox.Show(ex.Message)
    38.         End Try
    39.     End Sub
    40.  
    41. 'Lastly , do this
    42.  Private Sub Button1_Click(ByVal sender As System.Object, ByVal
    43. e As System.EventArgs) Handles Button1.Click
    44.         WriteXMLFile()
    45.         ReadXMLFile()
    46.     End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width