Public ObservableCollection causing crashes [closed] - windows-phone-7

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Whenever I make an ObservableCollection a public variable, as soon as the page is called with it on it the app crashes. What I'm trying to do is Add items to the public ObservableCollection from another class... I'll try to represent the structure below
Dir: Project/Class/PrepareSpells.xaml
public ObservableCollection<PublicVariables.Spell> level0 = new ObservableCollection<PublicVariables.Spell>();
Dir: Project/SpellLists/PopulateList.cs
Class.PrepareSpells prepare = new Class.PrepareSpells();
PublicVariables.Spell newSpell = new PublicVariables.Spell();
newSpell.spellLevel = 0;
newSpell.spellName = zeroName[i];
prepare.level0.Add(newSpell);
Please note that PopulateList is contained within a valid 'for' loop. I have also created an object for the PrepareSpells.xaml (prepare, above).
Is there a different way to do this or is it impossible? If I simply have an OC in the PopulateList whenever I manipulate it further (ie, to populate a higher spell level list) it modifies ALL the OC's in the PrepareSpells.xaml domain to reflect the new changes.
Please let me know if this is far too ambiguous and I will provide more code.

This is not an issue: I was inputting invalid data... I feel sheepish....

Related

r.PostForm() works only if I call before r.PostFormValue() [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 days ago.
Improve this question
As the title say, I have a code like this:
//if i don't use this line r.postform() don't works and return absolute nothing.
//html form works correctly
// I don't need to call r.PostFormValue for every key, just one
fmt.Println(r.PostFormValue("oldpass"))
if r.PostForm.Has("oldpass") && r.PostForm.Has("newpass1") && r.PostForm.Has("newpass2")
{ //if i don't call r.PostFormValue() the program stop before the if }
}
Make no sense to me... Also I remember to have used it without in the past, so I don't think it depend on parsing the value... What could be?

Class 'App\Http\Controllers\Project' not found in file C:\xampp\htdocs\chatend\app\Http\Controllers\ReqController.php on line 18 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
before this I have justified an error and this error appears afterwards, I have searched the sources but the results remain the same and I've seen the same problem in stackoverflow but still haven't gotten another correct response, please help
This clearly indicates you have a Model or similar you have not included.
You will probably have a class similar to this.
public class ReqController {
public function show($id)
{
return Project::find($id);
}
}
To make this work in your case, you need to include the Project model in the top of the file, i assumed the path is used as in the standard Laravel folder structure.
use App\Models\Project;

Trying to access array within a hash in ruby [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am trying to parse a hash in ruby. I have an array an array of 'entries'. I want to take each entity and get array of runs within it (I want to store the runs in a different variable as seen below). My problem is that runs always turns out nil. Below is my code:
entries = test_plan['entries']
entries.each do |ent|
puts "in entries"
puts ent
runs = ent['runs]']
runs.each do |run|
and what an 'entries' hash looks like.
{"id"=>"7", "suite_id"=>729, "name"=>"Regression", "runs"=>[{"id"=>2588, "suite_id"=>729}]}
There is a simple typo. Change
runs = ent['runs]']
to
runs = ent['runs']

Prepared Statement does not insert [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I am new to JDBC and trying following code. Could not find the error in it:
try{
Connection con = ConnectionProvider.getCon();
stmt=con.prepareStatement("insert into create_request values((select count(reqno) from create_request)+1,?,?,?,?,?)");
stmt.setString(1,obj_Leaverequest.getUser_name());
stmt.setString(2,obj_Leaverequest.getLeave_Type());
stmt.setInt(3,obj_Leaverequest.getLeave_Units());
stmt.setString(4,obj_Leaverequest.getLeave_Reason());
stmt.setString(5,"pending");
count=stmt.executeUpdate();
if(count>0){
status=true;
}
}
Update:
If I replace my code like this it works:
String sqQuery="insert into create_request values (?,?,?,?,?,?)";
stmt=con.prepareStatement(sqQuery);
stmt.setString(1,"(select count(reqno) from create_request)+1");
stmt.setString(2,obj_Leaverequest.getUser_name());
stmt.setString(3,obj_Leaverequest.getLeave_Type());
stmt.setInt(4,obj_Leaverequest.getLeave_Units());
stmt.setString(5,obj_Leaverequest.getLeave_Reason());
stmt.setString(6,"pending");
Getters are working fine, I could print their values. I guess I am wrong with the query. Please point out my mistake. Thanks in advance!!
String sqQuery="insert into create_request values (?,?,?,?,?,?)";
stmt=con.prepareStatement(sqQuery);
stmt.setString(1,"(select count(reqno) from create_request)+1");
stmt.setString(2,obj_Leaverequest.getUser_name());
stmt.setString(3,obj_Leaverequest.getLeave_Type());
stmt.setInt(4,obj_Leaverequest.getLeave_Units());
stmt.setString(5,obj_Leaverequest.getLeave_Reason());
stmt.setString(6,"pending");
Check for the "?" prepared statements index . You have 6 , but you need only 5
Hope this helps

Ruby detect if a column value has changed [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
So I have this line:
if self.company_changed?
And it works fine but this detects if the company has changed on the object. I need to know if the database value has changed and not if the value in memory has changed. So I tried this:
if :company_changed?
This seems to work in debug mode when I only execute the one line. If I let it run, it fails in testing on an infinite loop.
My question is what can be used in ruby to check to see if the column value has actually changed.
I'm pretty sure you're actually talking about ActiveRecord. In which case, you'd need to re-fetch the record to see if the value has changed in the database.
self.class.find(self.id).company != self.company
A general purpose method for this might be something like:
def attr_changed_in_db?(attr)
self.class.find(self.id).attributes[attr] != self.attributes[attr]
end
There is an excellent screencast on this by the great Ryan Bates.

Resources