Expand my Community achievements bar.

Inserting multiple records into a database from a table

Avatar

Former Community Member
I have a dynamic table with rows upto 10. i am trying to insert all the records in these rows into a database ( msaccess)

table name: Table1 ( in my form )

Database table : movies_comments ( as posted in stefan's forums ).

table columns: username, movieid, comments



i am using the following code.

Database.ExecSQL() function is as posted in stefcamerons forums.



var tlength = xfa.resolveNode("form1.#subform[0].Table1.Row1[*]").length;

xfa.host.messageBox("tlength is :" +tlength);



for ( var i = 1; i <= tlength; i++)

{

var username = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].user_name").rawValue;

var movieID = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].movie_id").rawValue;

var commentS = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].comment_").rawValue;



Database.ExecSQL("INSERT INTO movie_comments (username, movieId, comment) VALUES ('username','movieID', 'commentS');");

}



i am trying to insert multiple records using the code above. But i am getting error

GeneralError: Operation failed.

XFAObject.resolveNode:1:XFA:form1[0]:#subform[0]:Button1[0]:click

SOM expression returned list when single result was expected



suggest me an alternate way to insert multiple records from a table into a database.



thank Q
0 Replies