I'm adding a couble of fields to database but i need the primary key of the master table to add it to sub table.
The database contains 2 tables :
Question Table :questionID(primary key and identity) , questionInText
Answer table : answerID , answer1,answer2 , questionID
code used to insert to db :
Expand|Select|Wrap|Line Numbers
- string strInsert = "Insert INTO question(questionInText)Values(@questionInText)";
- cmdInsert = new SqlCommand(strInsert , conn);
- cmdInsert .Parameters.AddWithValue("questionInText", txtQuestion.Text);
- cmdInsert.ExecuteNonQuery();
The question is : How i get questionID after adding to database without using sql statment ?
please help.