1. Alexis Colon Lugo
  2. Valentina Server
  3. 月, 12月 30 2019, 07:55 PM
  4.  メールで購読
Send data from iOS On XOJO
This code works but it send only one record then have a error but k'now the error and the app close.
Any idea what is the problem
Thanks


Var sqlLocation As Text = App.mSessionURL + "/sql_fast"
Var v1,v2,v3,v4,v5,pic_as_text,er As Text
Var Rs As iOSSQLiteRecordSet
Var SqlStr As Text

SqlStr="Select * From AsambleaSocios Order BY numsocio"

Try
Rs=App.DBConn.SQLSelect(SqlStr)
Catch e As iOSSQLiteException
//ErrorLabel.Text = e.Reason
er= e.Reason
End Try

If Rs.RecordCount > 0 Then

Do

v1=Rs.Field("nombre";).TextValue
v2=Rs.Field("numsocio";).TextValue
v3=Rs.Field("fecha";).TextValue
v4=Rs.Field("hora";).TextValue
pic_as_text=Rs.Field("firma";).TextValue
v5=Rs.Field("distrito";).TextValue


Var sql As text = "INSERT INTO AsambleaSocios (nombre,numsocio,fecha,hora,firma,sync,distrito) VALUES ('"+ v1 + "','"+ v2 + "', '" + v3 + "', '" + v4 + "', '" + pic_as_text + "','Y','" +v5 + "')"

mSQLSocket.Start( App.mHost, App.mSessionID, sqlLocation, "SQLite", "ipadcrnew.db",sql)

Loop Until Rs.EOF=True

End If
コメント
There are no comments made yet.
Alexis Colon Lugo 承諾済みの回答
like this
sql=sql + "INSERT INTO AsambleaSocios (nombre,numsocio,fecha,hora,firma,sync,distrito) VALUES ('"+ v1 + "','"+ v2 + "', '" + v3 + "', '" + v4 + "', '" + pic_as_text + "','Y','" +v5 + "');"
no works
コメント
There are no comments made yet.
Sergey Pashkov 承諾済みの回答
Did you check the sql value in debugger? You should be able to copy/paste it to Valentina Studio.
Any message in Valentina Server log?
コメント
There are no comments made yet.
Alexis Colon Lugo 承諾済みの回答
In Valentina Studio it insert 2 record is perfect but when i send using iOS app it only insert 1 record
コメント
There are no comments made yet.
Sergey Pashkov 承諾済みの回答
Ok, we'll recheck it
コメント
There are no comments made yet.
Sergey Pashkov 承諾済みの回答
Yes, the problem with this approach.

But you can send multiple records in single INSERT:
INSERT INTO AsambleaSocios (nombre,numsocio,fecha,hora,firma,sync,distrito) VALUES ('v1','v2', 'v3', 'v4', 'pic_as_text','Y','v5'), ('2-v1','2-v2', '2-v3', '2-v4', '2-pic_as_text','Y','2-v5');

Additionally, you can use bound parameters, I'll show an example later (this would be the most efficient way).
コメント
There are no comments made yet.
Alexis Colon Lugo 承諾済みの回答
ok
thanks
after send some record i call mCloseSocket and the app crash with out error number i have no idea way.
コメント
There are no comments made yet.
Alexis Colon Lugo 承諾済みの回答
Now no more crash but only one record at same time
コメント
There are no comments made yet.
Sergey Pashkov 承諾済みの回答
after send some record i call mCloseSocket and the app crash

Can't reproduce anything like that, it is possible to debug step by step the CloseConnectionSocket to find out the line with an issue.

==
I attached a modified project where parameters are used.


Dim params() As Auto
Dim row1() As Auto
Dim row2() As Auto

row1.Append( 10000 )
row1.Append( "first1" )
row1.Append( "last1" )
row1.Append( "000" )

row2.Append( 10001 )
row2.Append( "first2" )
row2.Append( "last2" )
row2.Append( "000" )

params.Append(row1)
params.Append(row2)

mSQLSocket.Start( _
App.mHost,_
App.mSessionID,_
sqlLocation,_
"SQLite",_
"sqlite_sakila.sqlite",_
"INSERT INTO actor ( actor_id, first_name, last_name, last_update ) VALUES ( ?1, ?2, ?3, ?4 );",_
params)


With this approach, we send a single query and pass multiple records (2 in this example).
It is the most efficient way for such a task.
コメント
There are no comments made yet.
Alexis Colon Lugo 承諾済みの回答
thanks Sergey you the best help
コメント
There are no comments made yet.
  • ページ :
  • 1
  • 2


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 2 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories