Error while adding values into database
i m getting error while adding values into the database,
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Posted Jul 29, 2013, 2:49 AM EDT
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 2:55 AM EDT
public void AddQuestion(TestQuestion testToSave)
SERVICE
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 2:58 AM EDT
Posted Jul 29, 2013, 3:05 AM EDT
Please check it out once.
TestQuestionShort foo = new TestQuestionShort { TestQuestionId = Guid.NewGuid() };
_testQuestionRepo.AddQuestion(foo);
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 3:19 AM EDT
Is this correct r i need to change any?
Posted Jul 29, 2013, 3:25 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 29, 2013, 3:26 AM EDT
Try like this
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 3:27 AM EDT
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 3:33 AM EDT
"Object reference not set to an instance of an object."
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 3:34 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 29, 2013, 3:37 AM EDT
TestQuestion foo = new TestQuestion { TestId = Guid.NewGuid() };
Regards,
Iftikar
Posted Jul 29, 2013, 3:38 AM EDT
Posted Jul 29, 2013, 3:39 AM EDT
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 3:55 AM EDT
Posted Jul 29, 2013, 4:13 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 29, 2013, 4:30 AM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 7:31 PM EDT
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 8:08 PM EDT
I have already posted the code. please refer the above or specify the line.
If i use this also
TestQuestion foo = new TestQuestion { TestId = Guid.NewGuid() };
I am getting the error.
Object reference not set to an instance of an object.
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 8:39 PM EDT
I created the table TestQuestionShort from TestQuestionBlank by changingshort instead of blank. thats it, but i get different diagram in datamodel.
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 29, 2013, 8:48 PM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 8:54 PM EDT
{
}
It Represents a view model for a Short answer question.
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 29, 2013, 8:59 PM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 9:32 PM EDT
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 10:20 PM EDT
If i get the solution for this problem, i can resolve the error.
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 29, 2013, 10:48 PM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 29, 2013, 11:27 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 30, 2013, 12:18 AM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 30, 2013, 12:28 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 30, 2013, 12:34 AM EDT
I need to display the TestQuestionShort data model like TestQuestionBlank
what exactly you want
Regards,
Iftikar
Posted Jul 30, 2013, 12:42 AM EDT
TestQuestionBlank is inherited from TestQuestion that why the model has --> TestQuestion in the diagram. Because of the inheritance, the image or the model looks different but should be able to access all the properties from TestQuestion to TestQuestionBlank.
Properties Section:
All the properties of TestQuestion will be inherited to TestQuestionBlank. Parent class is TestQuestion and Child class TestQuestionBlank.
If you add properties to TestQuestionBlank that will not be available to TestQuestion.
Navigation Properties:
Navigation properties is used to navigate to parent collection by using navigation properites.
If you look at TestQuestionShort it has the navigation properties for TestQuestion. Based on the TestQuestionId you should be able to fetch all the TestQuestion.
Please let me know, if you're not clear.
vidhyaRank #4,868 · 321 reputationPosted Jul 30, 2013, 12:54 AM EDT
i replied before itself.
if i changed datamodel like testquestionblank, error will be resolved.
Posted Jul 30, 2013, 12:57 AM EDT
If you want to try, just inherit TestQuestionBlank from TestQuestionShort otherwise create a new one.
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 30, 2013, 1:01 AM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 30, 2013, 1:04 AM EDT
You did not understand what i am telling.
Same code work for testquestionblank. but not working testquestionshort .
If u observe clearly means u can identify the sql query format is same but name changed in short instead of blank. but i get different diagram in datamodel why?
Posted Jul 30, 2013, 1:07 AM EDT
vidhyaRank #4,868 · 321 reputationPosted Jul 30, 2013, 1:08 AM EDT
I cant inherit testquestionblank. i can inherit testquestion.
inheritance is missing in the datamodel for testquestionshort. How can i inherit it.
Posted Jul 30, 2013, 1:09 AM EDT
Please let me know, if you not clear.
Posted Jul 30, 2013, 1:10 AM EDT
vidhyaRank #4,868 · 321 reputationPosted Jul 30, 2013, 1:14 AM EDT
I get error:
Cannot find the object "dbo.TestQuestion_TestQuestionShort" because it does not exist or you do not have permissions.
vidhyaRank #4,868 · 321 reputationPosted Jul 30, 2013, 1:15 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 30, 2013, 1:17 AM EDT
Regards,
Iftikar
Posted Jul 30, 2013, 1:20 AM EDT
vidhyaRank #4,868 · 321 reputationPosted Jul 30, 2013, 1:28 AM EDT
Is this dispalying correctly according to the query
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 30, 2013, 1:29 AM EDT
Regards,
Iftikar
Posted Jul 30, 2013, 1:30 AM EDT
vidhyaRank #4,868 · 321 reputationPosted Jul 30, 2013, 1:51 AM EDT
vidhyaRank #4,868 · 321 reputationPosted Jul 30, 2013, 2:03 AM EDT