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

Calc, cells, macro and MySQL

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
larsbj
General User
General User


Joined: 06 Nov 2003
Posts: 20

PostPosted: Fri Feb 13, 2004 12:42 am    Post subject: Calc, cells, macro and MySQL Reply with quote

Hi All

I am sitting here and have to make some decisions. I have made a worksheet, retrieving values from a MySQL database, insert them in the worksheet, doing some caluclations, and so on. Now, my users are making requests to me. Shame on them. I even tried to look very sadly, but they are still making requests. They want to save their input to the worksheet, and give it a number for refrence. Numbering is no problem, it's just autoincrement in the MySQL. BUT there is a lot of cellvalues that have to be saved. A solution is :

Code:
Sub Main
  Dim oDocument As Object, oSheet As Object, oCell As Object
  oDocument=ThisComponent
  oSheet=oDocument.Sheets.getByName("Kunde")'Hvilket ark skal værdien rettes på
  oCell=oSheet.getCellByposition(1,16) '
  Kundeb17=oCell.getString
  oCell=oSheet.getCellByposition(1,17) '
  Kundeb18=oCell.getString
  oCell=oSheet.getCellByposition(1,18) '
  Kundeb19=oCell.getString
  oCell=oSheet.getCellByposition(1,19) '
  Kundeb20=oCell.getString
etc etc etc
End Sub


And then a long, long SQL statement like this :

Code:
DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
DataSource = DatabaseContext.getByName("Datakilde_4")
sSQL = "INSERT INTO adresser (Navn, Adresse, Postnummer) VALUES ('blabla', 'bla bla'," + Kundeb18 + ")"
DataSource.GetConnection("","").CreateStatement.ExecuteUpdate(sSQL)

This would work. But it's not smart. And if i want to make a revision, then i won't dare to think of the consequenses.

Making array's would be smarter, but still requires a long table in the database.

But the smartesed would be to save the entire worksheet in a single blobfield. But i've been googling around, and searched this forum, without any useful result ( The next step, if this could be solved, is to store writer document's )

But is there any other way's to solve this. Smart ?

Best Regards

Lars Brandi Jensen
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 Macros and API 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