hi
asp.net 2.0
I have a gridview which I'm trying to update a row within. When I click on
the Update button, my website crash. It displays a webpage saying that a
parameter is missing. So I wonder what's wrong in my code. Below I post
parts of my code
<asp:ObjectData Source ID="odsPhoneTyp e"
TypeName="SqlPh oneProvider"
SelectMethod="g etPhoneTypes" UpdateMethod="u pdatePhoneType"
InsertMethod="i nsertPhoneType" runat="server">
<UpdateParamete rs>
<asp:Paramete r Type="Int32" Name="Id" />
<asp:Paramete r Type="Char" Name="type" Direction="Inpu t" />
<asp:Paramete r Type="string" Name="desc" Direction="Inpu t" />
</UpdateParameter s>
<InsertParamete rs>
<asp:Paramete r Type="Char" Name="Type" />
<asp:Paramete r Type="string" Name="Desc" />
</InsertParameter s>
</asp:ObjectDataS ource
public override void updatePhoneType (int id, char type, string desc)
{
using (SqlConnection cn = new SqlConnection(t his.ConnectionS tring))
{
SqlCommand cmd = new SqlCommand("Upd atePhoneType", cn);
cmd.CommandType = CommandType.Sto redProcedure;
cmd.Parameters. Add("@id", SqlDbType.Int). Value = id;
cmd.Parameters. Add("@type", SqlDbType.NChar ).Value = type;
cmd.Parameters. Add("@desc", SqlDbType.NVarC har).Value = desc;
cn.Open();
cmd.ExecuteNonQ uery();
}
}
it complains about @desc, but I guess this problem is for @type also
any suggestions?
asp.net 2.0
I have a gridview which I'm trying to update a row within. When I click on
the Update button, my website crash. It displays a webpage saying that a
parameter is missing. So I wonder what's wrong in my code. Below I post
parts of my code
<asp:ObjectData Source ID="odsPhoneTyp e"
TypeName="SqlPh oneProvider"
SelectMethod="g etPhoneTypes" UpdateMethod="u pdatePhoneType"
InsertMethod="i nsertPhoneType" runat="server">
<UpdateParamete rs>
<asp:Paramete r Type="Int32" Name="Id" />
<asp:Paramete r Type="Char" Name="type" Direction="Inpu t" />
<asp:Paramete r Type="string" Name="desc" Direction="Inpu t" />
</UpdateParameter s>
<InsertParamete rs>
<asp:Paramete r Type="Char" Name="Type" />
<asp:Paramete r Type="string" Name="Desc" />
</InsertParameter s>
</asp:ObjectDataS ource
public override void updatePhoneType (int id, char type, string desc)
{
using (SqlConnection cn = new SqlConnection(t his.ConnectionS tring))
{
SqlCommand cmd = new SqlCommand("Upd atePhoneType", cn);
cmd.CommandType = CommandType.Sto redProcedure;
cmd.Parameters. Add("@id", SqlDbType.Int). Value = id;
cmd.Parameters. Add("@type", SqlDbType.NChar ).Value = type;
cmd.Parameters. Add("@desc", SqlDbType.NVarC har).Value = desc;
cn.Open();
cmd.ExecuteNonQ uery();
}
}
it complains about @desc, but I guess this problem is for @type also
any suggestions?
Comment