problem passing parameters

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?
 
J

Joe Fawcett

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?
 
J

Jeff

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,965
Messages
2,570,148
Members
46,710
Latest member
FredricRen

Latest Threads

Top