problem passing parameters

Discussion in 'ASP .Net' started by Jeff, Oct 22, 2008.

  1. Jeff

    Jeff Guest

    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, Oct 22, 2008
    #1
    1. Advertising

  2. Jeff

    Joe Fawcett Guest

    "Jeff" <> wrote in message
    news:...
    > 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?

    --

    Joe Fawcett (MVP - XML)
    http://joe.fawcett.name
     
    Joe Fawcett, Oct 22, 2008
    #2
    1. Advertising

  3. Jeff

    Jeff Guest

    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
     
    Jeff, Oct 22, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nikhil Patel

    problem passing parameters

    Nikhil Patel, May 3, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    595
    Nikhil Patel
    May 3, 2004
  2. Laura K

    datagrid passing parameters problem

    Laura K, Jan 11, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,882
    Otis Mukinfus
    Jan 11, 2005
  3. Ramon F Herrera
    Replies:
    8
    Views:
    484
    Pascal J. Bourguignon
    Sep 13, 2009
  4. davidbe
    Replies:
    1
    Views:
    126
    davidbe
    Jan 16, 2006
  5. Sherm Pendley
    Replies:
    6
    Views:
    104
    Vikrant
    Jul 1, 2005
Loading...

Share This Page