problem passing parameters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff

    problem passing parameters

    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?


  • Joe Fawcett

    #2
    Re: problem passing parameters



    "Jeff" <it_consultant1 @hotmail.com.NO SPAMwrote in message
    news:uE4fXlCNJH A.4600@TK2MSFTN GP06.phx.gbl...
    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?
    >
    Are you sure the updatePhoneType is called, can you put a breakpoint in
    there?

    --

    Joe Fawcett (MVP - XML)


    Comment

    • Jeff

      #3
      Re: problem passing parameters

      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


      Comment

      Working...