OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Fetching data from database (using Mysql)

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
uks
General User
General User


Joined: 26 Dec 2007
Posts: 16
Location: INDIA

PostPosted: Wed Jan 23, 2008 1:22 am    Post subject: Fetching data from database (using Mysql) Reply with quote

[/b]

Hello everybody...i have got a doubt on fetching data from database to a calcsheet using Mysql Connection.

i am working on Calc sheet.i have created a database named "Newdb7" [ Mysql Connection using JDBC drivers]. i have got tables in "Newdb7" with data.

The Task is--

If i run a macro, it should fetch data from database from the given table like select statement



how to do insert , update, select statements through macro????

Written Code:

sub uday

dim DatabaseContext

DatabaseContext= createUnoService("com.sun.star.sdb.RowSet")

DatabaseContext.DataSourceName = "Newdb7"
DatabaseContext.User="3ev2"
DatabaseContext.Password="3ev2"

dim insertToDB
dim txtname
dim SQLStatement
dim Result


SQLQuery="insert into uday(newschannel,language) values ('etv7','tamil')"

InsertDBContext=createUnoService("com.sun.star.sdb.DatabaseContext")
DataSource=InsertDBContext.getByName("Newdb7")
ConnectToDB=DataSource.GetConnection ("3ev2","3ev2")
SQLStatement=ConnectToDB.createStatement
msgbox SQLQuery
Result= SQLStatement.executeQuery(SQLQuery)
ConnectToDB.close
ConnectToDB.dispose()

end sub




i don't know whats wrong with this?? can anybody please help me??

thanks in advance
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Wed Jan 23, 2008 6:47 am    Post subject: Reply with quote

This is exactly what database forms are made for.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group