Saturday, January 31, 2015

@reference0 must be defined error message when creating parameters in for loop before SQL insert query

Have you looked at the string it produces?


There's no ; on the end of each insert.


First thing I would suggest you try is adding that on:



query +=
@"INSERT INTO waypoint
(booking_id, sequence, address, lat, lng, reference)
VALUES
((select id FROM booking WHERE reference=@reference" + i + @"),
@sequence" + i + @",
@address" + i + @",
@lat" + i + @",
@lng" + i + @",
@reference" + i + ");";

Note the ; added to the last line there.



Please don't forget to upvote posts which you like and mark those which answer your question.

My latest Technet article - Dynamic XAML


No comments:

Post a Comment