/////编译的方法
public int addnputgod3(string D, string N, string P)
{
SqlParameter[] paras = new SqlParameter[3];
paras[0] = new SqlParameter("@GoodsID", SqlDbType.Int);
paras[0].Value =int.Parse(D);
paras[1] = new SqlParameter("@GoodsName", SqlDbType.NVarChar, 50);
paras[1].Value = N;
paras[2] = new SqlParameter("@GoodsPrice", SqlDbType.Money);
paras[2].Value =P; int i=com.ExecuteNonQuery("AddgoodInput3", CommandType.StoredProcedure, paras);
return i;
//com.ExecuteNonQuery(addgodProc, CommandType.StoredProcedure, paras);
//return i; }
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox2");
string GD = ((TextBox)GridView1.Rows[i].FindControl("Label2")).ToString();
string GN = ((TextBox)GridView1.Rows[i].FindControl("Label1")).ToString();
string GP = ((TextBox)GridView1.Rows[i].FindControl("Label3")).ToString();
if(cbox.Checked==true)
{ int i1 = Md.addnputgod3(GD,GN,GP);//调用的方法
if (i1 == 1)
{
Response.Write("javascript:return confirm('添加成功!;location.href='GoodsInfo.aspx';");
}
}
}
}这样添加为什么报错?
错误为:输入字符串的格式不正确。
public int addnputgod3(string D, string N, string P)
{
SqlParameter[] paras = new SqlParameter[3];
paras[0] = new SqlParameter("@GoodsID", SqlDbType.Int);
paras[0].Value =int.Parse(D);
paras[1] = new SqlParameter("@GoodsName", SqlDbType.NVarChar, 50);
paras[1].Value = N;
paras[2] = new SqlParameter("@GoodsPrice", SqlDbType.Money);
paras[2].Value =P; int i=com.ExecuteNonQuery("AddgoodInput3", CommandType.StoredProcedure, paras);
return i;
//com.ExecuteNonQuery(addgodProc, CommandType.StoredProcedure, paras);
//return i; }
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox2");
string GD = ((TextBox)GridView1.Rows[i].FindControl("Label2")).ToString();
string GN = ((TextBox)GridView1.Rows[i].FindControl("Label1")).ToString();
string GP = ((TextBox)GridView1.Rows[i].FindControl("Label3")).ToString();
if(cbox.Checked==true)
{ int i1 = Md.addnputgod3(GD,GN,GP);//调用的方法
if (i1 == 1)
{
Response.Write("javascript:return confirm('添加成功!;location.href='GoodsInfo.aspx';");
}
}
}
}这样添加为什么报错?
错误为:输入字符串的格式不正确。
解决方案 »
- 数据插入Access报错..字段丢失,求帮助!
- 分享一点代码(小型C web开发框架)共11篇章 (含全部源代码),范例:用C语言实现的一个WEB 文件上传
- 网页分块显示怎么做
- [总结] ASP.NET 选择题
- 我IE無法使用frameset,不管是ie,還是firefox
- 找不到类型或命名空间名ADOX(是否缺少using指令或程序集引用?)和找不到类型或命名空间名JRO(是否缺少using指令或程序集引用?)
- 博客中如何传替多个用户名或者ID---顶者有分
- 如果C#的代碼是放在aspx頁面中時,在將程序交給客戶使用時,如何保掮這部分代碼
- 关于数据更新的问题
- 在数据还没有读完之前出现“正在读取数据....,请稍候”如何实现~~~~
- 大侠们,水有JS代码写的一个像迅雷高清下载首页的那个大图点上去变图片
- 跪求 外汇信号接口
确定这个能转化? 直接把你报错的那一句贴出来看看好了,调试下 就能发现是那一句话错误了。。也很容易发现问题...另外 去提高你的结贴率吧.
字符串不能被转换成数字输入的内容有问题
//FindControl找到的是一个Label 为什么要转换成TextBox??
Label lbl1 = (Label)GridView1.Rows[i].FindControl("Label2");
Label lbl2 = (Label)GridView1.Rows[i].FindControl("Label1");
Label lbl3 = (Label)GridView1.Rows[i].FindControl("Label3");
if(cbox.Checked==true)
{ int i1 = Md.addnputgod3(lbl1.Text,lbl2.Text,lbl3.Text);//调用的方法
}
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.FormatException: 输入字符串的格式不正确。源错误:
行 52:
行 53: opencom(comtext, comtype, paras);
行 54: int i = com.ExecuteNonQuery();
行 55: closecon();
行 56: return i;
源文件: C:\Users\SUNYUN\Documents\Visual Studio 2010\Projects\商品进销\WebApplication1\Class&&methods\Common.cs 行: 54 堆栈跟踪:
我的存储过程是这样的:
USE [Good]
GO
/****** Object: StoredProcedure [dbo].[deletegod] Script Date: 11/28/2011 14:37:18 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[deletegod]
@GoodsID int
asdelete from GoodsInfo where GoodsID=@GoodsID
select*from GoodsInfo
改后代码: for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox2");
Label GD = ((Label)GridView1.Rows[i].FindControl("Label2")); int i1 = Md.deleteGodinfo(GD.Text);
if(cbox.Checked==true)
{
if (i1 == 1)
{
//Response.Write("<script>alert('删除成功!');location.href='GoodsInfo.aspx';</script>");
Response.Write("javascript:return confirm('删除成功!;location.href='GoodsInfo.aspx';");
}
}
}
有出现下列错误
;“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------为过程或函数 deletegod 指定了过多的参数。
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 为过程或函数 deletegod 指定了过多的参数。源错误:
行 52:
行 53: opencom(comtext, comtype, paras);
行 54: int i = com.ExecuteNonQuery();
行 55: closecon();
行 56: return i;