protected void Button1_Click(object sender, EventArgs e)
{
try
{
SqlAddGroup.InsertParameters["mem_email"].DefaultValue = Session["User"].ToString();
SqlAddGroup.InsertParameters["groupname"].DefaultValue = Txtgroup.Text;
SqlAddGroup.Insert();
Label1.Text = "Group has been added";
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
<asp:SqlDataSource ID="SqlAddGroup" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:PadmaSMSConnectionString %>"
DeleteCommand="DELETE FROM [group] WHERE [sno] = @original_sno AND [mem_email] = @original_mem_email AND [groupname] = @original_groupname"
InsertCommand="INSERT INTO [group] ([mem_email], [groupname], [sno]) VALUES (@mem_email, @groupname, @sno)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [group] WHERE ([mem_email] = @mem_email)"
UpdateCommand="UPDATE [group] SET [mem_email] = @mem_email, [groupname] = @groupname WHERE [sno] = @original_sno AND [mem_email] = @original_mem_email AND [groupname] = @original_groupname">
<DeleteParameters>
<asp:Parameter Name="original_sno" Type="Int32" />
<asp:Parameter Name="original_mem_email" Type="String" />
<asp:Parameter Name="original_groupname" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="mem_email" Type="String" />
<asp:Parameter Name="groupname" Type="String" />
<asp:Parameter Name="sno" Type="Int32" />
</InsertParameters>
<SelectParameters>
<asp:SessionParameter Name="mem_email" SessionField="User" Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="mem_email" Type="String" />
<asp:Parameter Name="groupname" Type="String" />
<asp:Parameter Name="original_sno" Type="Int32" />
<asp:Parameter Name="original_mem_email" Type="String" />
<asp:Parameter Name="original_groupname" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
My problem is that I am getting this exception whenever i run the code for insertion. Can someone please help me discover where exactly am I going wrong?