Note that there are some explanatory texts on larger screens.

plurals
  1. POSave From Gridview using a WCF
    primarykey
    data
    text
    <p>so I am using Gridview with a WCF. I have managed to insert from textboxes to gridiview but now I am struggling to save the gridview via the WCF service. I have giving it an attempt and getting this error:</p> <blockquote> <p>"The parametrized query '(@Item1 narchar(4),@Item2 nvarchar(4000)) insert into ' expects the parameter '@item2', which was not supplied."</p> </blockquote> <p>here is my code:</p> <pre><code>public string InsertProcesses(ProcessDetails proDetails) { string Message; SqlConnection con = new SqlConnection(@"Data Source=localhost;Initial Catalog=WCFTest;Integrated Security=True;Pooling=False"); con.Open(); SqlCommand cmd = new SqlCommand("insert into SaveProcesses(Item1, Item2)values(@Item1, @Item2)", con); cmd.Parameters.AddWithValue("@Item1", proDetails.Item1); cmd.Parameters.AddWithValue("@Item2", proDetails.Item2); int result = cmd.ExecuteNonQuery(); if (result == 1) { Message = proDetails.Item1+ "Details accepted"; } else { Message = proDetails.Item1+ "Details not accepted"; } con.Close(); return Message; } for (int i = 0; i &lt; dataGridView2.Rows.Count; i++) { ServiceReference6.ProcessDetails det2 = new ServiceReference6.ProcessDetails(); det2.Processes = dataGridView2.Rows[i].Cells["Item1"].Value.ToString(); det2.Processes = dataGridView2.Rows[i].Cells["Item2"].Value.ToString(); obj6.InsertProcesses(det2); </code></pre> <p>Thanks for any help that can be given. Please note this is my first time attempting a WCF.</p> <p><strong>ProcessDetail code</strong></p> <pre><code>[DataContract] public class ProcessDetails { int id; string item1; string item2; [DataMember] public int Id { get { return id; } set { id = value; } } [DataMember] public string Item1 { get { return item1; } set { item1 = value; } } [DataMember] public string Item2 { get { return item2; } set { item2 = value; } } } </code></pre>
    singulars
    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.
    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