Support Forum

Ask questions and get help from MobileTogether experts.
MobileTogether Product Information
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
View
Go to last post Go to first unread
nigel  
#1 Posted : Thursday, February 2, 2017 1:47:12 PM(UTC)
nigel

Rank: Advanced Member

Groups: Registered
Joined: 1/20/2017(UTC)
Posts: 59
United Kingdom
Location: sussex

Thanks: 1 times
Have you got an example mtd of saving persistent xml elements to sql server database where it saves each element as an attribute.
I followed the tutorial but it gave me errors on the code and also on the primary key.
The code I used was
element row {
for $i in $PERSISTENT/Root/Current/Job/*
return attribute { $i/name() } { $i/item() }
}
and this did not like the item() part.
Also to update a single attribute would also be good.

Thanks
bbv  
#2 Posted : Thursday, February 2, 2017 5:29:10 PM(UTC)
bbv

Rank: Administration

Groups: Registered, Administrators
Joined: 7/21/2014(UTC)
Posts: 498

Was thanked: 88 time(s) in 88 post(s)
Hi Nigel,

I see an error in your XPath, it should be

$i/text() instead of $i/item()

But I don't know actually what you are trying to do, because your explanation is unclear.

Can you describe your sql server table structure and maybe attach your design file again, so that we can suggest you how to save it right.

Actually writing to databases is very easy and well documented. But you seem to do something special, therefore we need more details
nigel  
#3 Posted : Thursday, February 2, 2017 5:48:15 PM(UTC)
nigel

Rank: Advanced Member

Groups: Registered
Joined: 1/20/2017(UTC)
Posts: 59
United Kingdom
Location: sussex

Thanks: 1 times
I have now made this work and it shows that the sql database is holding the input values in the simultation, on the right hand side.
Below is the messages from the bottom of the screen.

Append Node '$PERSISTENT/Root/Current/Job' successfully appended to '$DB1/DB/RowSet'.
Executed on server: Control Action of Button Save:
Executed on server: Save '$DB1' (Database: Data Source=xxx.xxx.xxx.xxx;Initial Catalog=ScottApp;Persist Security Info=True;Provider=SQLOLEDB.1)
Simulation - 0 error(s), 0 warning(s)

But the data does not appear on the remote server in the sql database, although if I put a table in to display the data on the sql server, and manually put data into the database, it does display this.
bbv  
#4 Posted : Thursday, February 2, 2017 6:00:34 PM(UTC)
bbv

Rank: Administration

Groups: Registered, Administrators
Joined: 7/21/2014(UTC)
Posts: 498

Was thanked: 88 time(s) in 88 post(s)
As a quick guess (without seeing your file) can you change

element row {

to

element Row {

case is significant
nigel  
#5 Posted : Thursday, February 2, 2017 6:12:21 PM(UTC)
nigel

Rank: Advanced Member

Groups: Registered
Joined: 1/20/2017(UTC)
Posts: 59
United Kingdom
Location: sussex

Thanks: 1 times
I have changed all the persistent data to attributes so I am now just using append to node on the save button. This is the same cdode as I used when writing to a persistent history file.
So I append to node:- $DB1/DB/RowSet
new node:- $PERSISTENT/Root/Current/Job

Then I use save $DB1 after the append.

and get the report:-Append Node '$PERSISTENT/Root/Current/Job' successfully appended to '$DB1/DB/RowSet'.
Executed on server: Control Action of Button Save:
Executed on server: Save '$DB1' (Database: Data Source=xxx.xxx.xxx.xxx;Initial Catalog=ScottApp;Persist Security Info=True;Provider=SQLOLEDB.1)
bbv  
#6 Posted : Thursday, February 2, 2017 6:15:57 PM(UTC)
bbv

Rank: Administration

Groups: Registered, Administrators
Joined: 7/21/2014(UTC)
Posts: 498

Was thanked: 88 time(s) in 88 post(s)
Ok, and I guess Job element contains your attributes? You have to add Row element nevertheless

element Row { $PERSISTENT/Root/Current/Job/@* }

this will create a Row element with attributes from Job
nigel  
#7 Posted : Friday, February 3, 2017 12:38:44 PM(UTC)
nigel

Rank: Advanced Member

Groups: Registered
Joined: 1/20/2017(UTC)
Posts: 59
United Kingdom
Location: sussex

Thanks: 1 times
Thank you for your previous help. I have now got the persistent data updating the remote sql server database with an auto sequence ID.
The final part of this app is the ability to select from the sql database (loaded into a table), which is working.
Then load the selected into the persistent data and edit the data. Then it needs to write back into the sql server using the same auto genrated number.
I get an error when trying to append the data into the persistent data, which is spread across numtiple pages.
bbv  
#8 Posted : Friday, February 3, 2017 12:59:52 PM(UTC)
bbv

Rank: Administration

Groups: Registered, Administrators
Joined: 7/21/2014(UTC)
Posts: 498

Was thanked: 88 time(s) in 88 post(s)
What error? I really need as many details as possible (or your project).
nigel  
#9 Posted : Friday, February 3, 2017 1:47:24 PM(UTC)
nigel

Rank: Advanced Member

Groups: Registered
Joined: 1/20/2017(UTC)
Posts: 59
United Kingdom
Location: sussex

Thanks: 1 times
.
nigel  
#10 Posted : Friday, February 3, 2017 1:51:55 PM(UTC)
nigel

Rank: Advanced Member

Groups: Registered
Joined: 1/20/2017(UTC)
Posts: 59
United Kingdom
Location: sussex

Thanks: 1 times
I am attaching the project so you click on the logo/sc reports/sc report and then click on select.
This then lists all the jobs in the sql server database. I then need to select a job and put the data into the pages (persistent) so it can be edited and then saved back to the sql server database using the same auto number in ID.
bbv  
#11 Posted : Friday, February 3, 2017 2:13:51 PM(UTC)
bbv

Rank: Administration

Groups: Registered, Administrators
Joined: 7/21/2014(UTC)
Posts: 498

Was thanked: 88 time(s) in 88 post(s)
It tells you that it cannot append attribute because there is already one.

All you need is to delete current attributes from $PERSISTENT before attaching new ones

Delete Node(s) $PERSISTENT/Root/Current/Job/@*

and then execute your Append Node
nigel  
#12 Posted : Friday, February 3, 2017 2:39:34 PM(UTC)
nigel

Rank: Advanced Member

Groups: Registered
Joined: 1/20/2017(UTC)
Posts: 59
United Kingdom
Location: sussex

Thanks: 1 times
I thought I had tried that but maybe I missed the *
Thank you.
bbv  
#13 Posted : Friday, February 3, 2017 3:23:09 PM(UTC)
bbv

Rank: Administration

Groups: Registered, Administrators
Joined: 7/21/2014(UTC)
Posts: 498

Was thanked: 88 time(s) in 88 post(s)
Don't worry - you are progressing quickly!
By the way, I would suggest to remove the file again from this public forum, because of the open DB access
nigel  
#14 Posted : Friday, February 3, 2017 3:28:22 PM(UTC)
nigel

Rank: Advanced Member

Groups: Registered
Joined: 1/20/2017(UTC)
Posts: 59
United Kingdom
Location: sussex

Thanks: 1 times
Thank you for your help, I have just sorted enabled/editable after selection so I can control the rewrite with a unique number and then I am onto creating pdf's. So wish me luck.
Users browsing this topic
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.