By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,061 Members | 1,563 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,061 IT Pros & Developers. It's quick & easy.

problem passing parameters

P: n/a
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?
Oct 22 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a


"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:uE**************@TK2MSFTNGP06.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: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

Oct 22 '08 #2

P: n/a
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
Oct 22 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.