Android Question Writing same time both String and Object?

Itila Tumer

Active Member
Licensed User
Longtime User
I have image and a blob (photo) taken from galary via contentchooser, how can I Insert Into Database at the sametime ?
B4X:
Query = "INSERT INTO persons VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)"
Activity2.SQL1.ExecNonQuery2(Query, ArrayAsString(edtFirstName.Text, edtLastName.Text, spnCinsiyet.SelectedItem, edtBirthDay.Text, edtBirthCity.Text, edtFatherName.Text))
Query ="INSERT INTO persons VALUES( NULL, NULL,NULL, NULL,NULL, NULL, NULL, ?)"
Activity2.SQL1.ExecNonQuery2(Query, ArrayAsObject(Buffer))
 

eps

Expert
Licensed User
Longtime User
What are you trying to ultimately achieve? If you are looking for some way to link them, then a foreign key or similar should be used. You will _not_ be able to insert both records at precisely the same time, there will always be a difference. You could add a field which holds an arbitrary time value but this could cause issues and seems illogical, as mentioned the best way is to give both records a unique foreign key to link them together _or_ combine them into one record, which is what you are attempting to achieve.
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
As I understand , I cannot Insert into at the same time in to same row, then I can intsert photos another table which is related same Id (RMDS)

Otherwise I tried so many methods but I couldn't achive. There are always difference one row earylier or later
 
Upvote 0

eps

Expert
Licensed User
Longtime User
Yes, relate by an id, I guess that this will achieve what you are attempting to do and is a more conventional approach to what I think you are attempting to achieve, which is link a thumbnail to an image stored..?
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
yes you can combine two data types .. ArrayAsObject
B4X:
Query = "INSERT INTO persons VALUES (NULL, ?, ?, ?, ?, ?, ?, ?)"
Activity2.SQL1.ExecNonQuery2(Query, ArrayAsObject(edtFirstName.Text, edtLastName.Text, spnCinsiyet.SelectedItem, edtBirthDay.Text, edtBirthCity.Text, edtFatherName.Text , Buffer))

your Code in post #1 would result in 2 records being written ... Ist one all data and no image, the second , No data and an Image.

edit.. Is this statement in Activity2 ? ...
 
Last edited:
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
I worked MangoJack, thank you. I really greatful ,thank you so much mangojack and eps for answering and useful information.
By the way, I have splash screen first ,Activity 2 is like my main menu, I click ADD button or EDIT , I go to Edit mode or ADD mode which is my Edit Activity.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Itala .. Glad to hear you have solved your problem ... I can now concentrate on my own app now ! ..:D
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
I had a problem and the problem was
I add person Information and I go to galery for taking photo. After I took photo ,all data lose which is entered before.
How can I save entered data?
But I handle it.And I woudl want to share it with others my solution, because I couldn't see the any issue HERE THE LINK

Opss I had another problem now. I 'll check it again :oops:
 
Upvote 0
Top