problem passing parameters

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

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:ObjectDataSource ID="odsPhoneType"
TypeName="SqlPhoneProvider"
SelectMethod="getPhoneTypes" UpdateMethod="updatePhoneType"
InsertMethod="insertPhoneType" runat="server">
<UpdateParameters>
<asp:Parameter Type="Int32" Name="Id" />
<asp:Parameter Type="Char" Name="type" Direction="Input" />
<asp:Parameter Type="string" Name="desc" Direction="Input" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Type="Char" Name="Type" />
<asp:Parameter Type="string" Name="Desc" />
</InsertParameters>
</asp:ObjectDataSource

public override void updatePhoneType(int id, char type, string desc)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("UpdatePhoneType", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@id", SqlDbType.Int).Value = id;
cmd.Parameters.Add("@type", SqlDbType.NChar).Value = type;
cmd.Parameters.Add("@desc", SqlDbType.NVarChar).Value = desc;
cn.Open();
cmd.ExecuteNonQuery();
}
}

it complains about @desc, but I guess this problem is for @type also

any suggestions?
 
Jeff said:
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:ObjectDataSource ID="odsPhoneType"
TypeName="SqlPhoneProvider"
SelectMethod="getPhoneTypes" UpdateMethod="updatePhoneType"
InsertMethod="insertPhoneType" runat="server">
<UpdateParameters>
<asp:Parameter Type="Int32" Name="Id" />
<asp:Parameter Type="Char" Name="type" Direction="Input" />
<asp:Parameter Type="string" Name="desc" Direction="Input" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Type="Char" Name="Type" />
<asp:Parameter Type="string" Name="Desc" />
</InsertParameters>
</asp:ObjectDataSource

public override void updatePhoneType(int id, char type, string desc)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("UpdatePhoneType", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@id", SqlDbType.Int).Value = id;
cmd.Parameters.Add("@type", SqlDbType.NChar).Value = type;
cmd.Parameters.Add("@desc", SqlDbType.NVarChar).Value = desc;
cn.Open();
cmd.ExecuteNonQuery();
}
}

it complains about @desc, but I guess this problem is for @type also

any suggestions?
Are you sure the updatePhoneType is called, can you put a breakpoint in
there?
 
Are you sure the updatePhoneType is called, can you put a breakpoint in
there?

Yes, I put a breakpoint in that method and it get triggered during runtime
 
Back
Top