Note that there are some explanatory texts on larger screens.

plurals
  1. POC# or SQL for most efficient solution
    primarykey
    data
    text
    <p>I have a questionaire; there are no right or wrong answers, simply "expert, intermediate, beginner" which have values 3,2,1.</p> <p>The questions are split up into various groups, i.e. math, geography, etc. I have built a "content management system" that will allow the administrator to add groups as well as questions for each group, therefore I have an unknown number of questions and groups.</p> <p>I tried and tried to write SQL to loop through the input but had no success. The only way I found to do it is in C# as follows;</p> <pre><code>logonName = Session["user"].ToString(); foreach (GridViewRow gvr in GridView1.Rows) { var rb = gvr.FindControl("answers_list") as RadioButtonList; var quest = rb.SelectedValue; if (quest == "") { quest = "0"; } var questId = GridView1.DataKeys[gvr.RowIndex].Values[0].ToString(); var gpId = GridView1.DataKeys[gvr.RowIndex].Values[1].ToString(); int questionId = Convert.ToInt32(questId); int groupId = Convert.ToInt32(gpId); int question = Convert.ToInt32(quest); var objDB01 = new dbconn(); const string strSQL = "insertResults"; objDB01.objCommand.Parameters.AddWithValue("@userId", logonName); objDB01.objCommand.Parameters.AddWithValue("@groupId", groupId); objDB01.objCommand.Parameters.AddWithValue("@questionId", questionId); objDB01.objCommand.Parameters.AddWithValue("@answer", question); try { objDB01.GetNonQuery(strSQL); } finally { objDB01.Dispose(); } } </code></pre> <p>Is there a more efficient way to do this? What kind of stress is this putting on the server as once this is rolled out, there could be hundred of users answering hundreds of questions simultaneously?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload