Normal Topic Importing a full record of a database (Read 999 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Importing a full record of a database
Apr 23rd, 2015 at 9:02pm
Print Post Print Post  
I have a database with several forms that is sharing  some key common fields information. Such as file#, Name , etc. If so happened that a record is deleted by mistake or inadvertent event in the main form with important key data being deleted in all the forms, so I cannot retrieve the records in the other forms using the key field data. Now I am left with the challenge to reconstruct the data of this particular record in all the different forms. I do have the backup copy from that I can get the exported data from the various forms of the record and import in all the forms of the record.

Instead is there a way to get the whole record using xResultset ( ) command that could be automatically parse in the individual forms?  How?
« Last Edit: Apr 24th, 2015 at 12:14pm by Bharat_Naik »  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Importing a full record of a database
Reply #1 - Apr 24th, 2015 at 12:51pm
Print Post Print Post  
I was going over the old posts and see the same issue addressed in the following thread..
http://lantica.com/Forum4/cgi-bin/yabb2/YaBB.pl?num=1368471003/6#6

Mark made the suggestion and comment

Quote:
We may be able to do something more direct here by bypassing the forms and exporting/importing directly from and to records.

I am also considering some kind of "master form" facility for Sesame3. You might want to build one by hand for your nine-form record for future use.


Just wondering if anything like above is available now? If it is, then that would solve the problem.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2483
Joined: Aug 20th, 2003
Re: Importing a full record of a database
Reply #2 - Apr 27th, 2015 at 1:12pm
Print Post Print Post  
Hello Bharat,

There is not currently in Sesame 2, if you do not have a form that has an element bound to each field on it. But what you can do is write an Sbasic routine that gets the data from the fields themselves using @XResultSetValue() and then write it out to a text file as a delimited string. Then write an Sbasic routine that parses the data from the text file and places it into individual fields using XResultSetValue().

You will need to get a list of all the fields in your database which can be done by using a combination of @StringArrayElementList(), SetThisElement(), ThisElement, @ElementBoundToType(), @ElementBoundTo(), @AppendStringArray(), and Write() on each of your forms to get a StringArray list of the fields that particular form references. Do this on each form and then use @AppendStringArray() and @UniqueStringArray() to get a unique StringArray of all the fields that are currently in use.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Importing a full record of a database
Reply #3 - Apr 27th, 2015 at 4:00pm
Print Post Print Post  
Thanks Ray. I have made  sBasic routine to take the data in individual forms.. works ok for now.

It is basically Generic code, so I can use for each form using Massupdate on the single record.

Code
Select All
var vList as String
var n as Int
var vName as String
var vCount as Int
var vReturnValue as String
var vString as String
var vStr as String



If @AskUser("Have you placed the BACK UP OF " + @Application + ".db" + " into 'c:\backup' folder?", "", "") then

	{


			Vlist = @stringArrayElementList( )
			vCount = @CountStringArray (vList)
			//WriteLn (VList)

			n = 1

			While n <= vCount
				{
					vStr = @AccessStringArray (vList, n)

					SetThisElement ( vStr)
					If @ElementBoundToType (ThisElement) >=3 and @ElementBoundToType (ThisElement) <=6 then
						{
							If vString = "" then
								{
									vString = vStr

								}
								Else
								{
									vString = vString + ";" + vStr
								}

						}


					n = n + 1

				}


			UnsetThisElement ( )


			//WriteLN (vString)


			vReturnValue  = @XLookupSourceList("C:\backup\" + @Application + ".db", RecNumber, @Layout + "!RecNumber", vString)
			//WriteLN (vReturnValue)


			vCount = @CountStringArray (vString)


			n =1
			While n <= vCount
				{
					vName = @AccessStringArray (vString, n)

					SetThisElement ( vName)
					ThisElement = @AccessStringArray (vReturnValue, n)

					n = n + 1


				}
			UnsetThisElement ( )

			@MSGBOX ("Hit F10 to save to save the record if everything is as expected", "If not, just hit escape and troubleshoot", "" )
	}
	Else
	{

		@MSGBox ("Please put backup of " + @Application + ".db " + "into c:\backup folder first", "", "" )

	}

 

  
Back to top
 
IP Logged