LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-02-2009, 03:03 AM   #1
sriphp
Member
 
Registered: Apr 2009
Posts: 48

Rep: Reputation: 15
openOffice data into mysql


Hai all,

This is sri

i am trying to insert openoffice doc data in to mysql table from openOffice. for that i done

installed openOffice base on fedora

and opened my document in openOffice

in tools ->macros -> organise macros -> OpenOffice.org Basic and for my document i created new macro 'mymac' and saved

mymac code
------------
(first i am testing to insert any text in mysql)
(i want to take mysql connection and select database)
Sub Main
oDBCntxt = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oDBSrc = oDBCntxt.getByName( "newdb" ) //newdb is my database in mysql
oConnection = oDBSrc.getConnection("root","srinath")
oStatement = oConnection.CreateStatement

sSQL = sSQL & "insert into tblTest ( Id, data ) values( null, 'ddd' );"
oStatement.execute( sSQL)

End Sub

now when i run that macro at tools ->macros -> run macros
i am getting error dialog like

BASIC Error
An exception occurred
Type: com.sun.star.container.NoSuchElementException
Message: newdb

i don't know statements for reading my doc file here tell me how that also

please tell me how to solve this.

Thanks
Sri
 
Old 06-02-2009, 05:42 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,937

Rep: Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692Reputation: 3692
Quote:
Originally Posted by sriphp View Post
Hai all,

i am trying to insert openoffice doc data in to mysql table from openOffice. for that i done

installed openOffice base on fedora

and opened my document in openOffice

mymac code
------------
(first i am testing to insert any text in mysql)
(i want to take mysql connection and select database)
Sub Main
oDBCntxt = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oDBSrc = oDBCntxt.getByName( "newdb" ) //newdb is my database in mysql
oConnection = oDBSrc.getConnection("root","srinath")
oStatement = oConnection.CreateStatement

sSQL = sSQL & "insert into tblTest ( Id, data ) values( null, 'ddd' );"
oStatement.execute( sSQL)

End Sub

now when i run that macro at tools ->macros -> run macros
i am getting error dialog like

BASIC Error
An exception occurred
Type: com.sun.star.container.NoSuchElementException
Message: newdb
Either your MySQL database isn't created, the table IN the database isn't created, or you're having a problem with the data. You haven't posted any sample data, or any details about the table, so it's hard to say. The insert looks suspicious...inserting a null? And where is the 'ddd' value defined??

Quote:
i don't know statements for reading my doc file here tell me how that also

please tell me how to solve this.
Don't know what you mean by this...do you mean how do you POST a part of your doc? Open the doc...copy some out...paste into the box, preferable with CODE tags around it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I get data out of MySQL if I can access the HD, but not run MySQL DJOtaku Linux - Server 4 01-11-2009 08:30 PM
Processing data from a 'foreign' database with mysql, or tools to pre-process data. linker3000 Linux - Software 1 08-14-2007 09:36 PM
OpenOffice keeps asking for user data jdtiede Linux - Software 2 03-20-2004 02:47 PM
OpenOffice Data Source Informix SteveT Linux - General 1 10-31-2003 04:04 AM
data import into openoffice calc general4172 Linux - Software 0 09-24-2003 01:45 PM


All times are GMT -5. The time now is 04:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration