关于在asp中用存储过程操作数据库遇到的问题,很急!!!
时间:2011-12-12
来源:互联网
先说一个没有问题的,是更新数据的,存储过程为
[code=SQL][/code]ALTER PROCEDURE insert_customer
(
@customid [char] (10),
@customname [char] (10),
@customcharge [char] (10),
@customdesc [varchar] (100),
@customlevel [int]
)
AS
insert into [corporation].[dbo].[customer]
(
[CustomID],
[CustomName],
[CustomCharge],
[CustomDesc],
[CustomLevel]
)
values
(
@customid,
@customname,
@customcharge,
@customdesc,
@customlevel
)
RETURN
asp中的代码就不贴了,
再看下出错的,很不解:
[code=SQL][/code]ALTER PROCEDURE update_customer
(
@customid [char] (10),
@oldcustomid [char] (10),
@customname [char] (10),
@customcharge [char] (10),
@customdesc [varchar] (100),
@customlevel [int]
)
AS
update [corporation].[dbo].[customer]
set
[CustomID] = @customid,
[CustomName] = @customname,
[CustomCharge] = @customcharge,
[CustomDesc] = @customdesc,
[CustomLevel] = @customlevel
where
(CustomID = @oldcustomid)
RETURN
报错说[corporation].[dbo].[customer]对象名无效,为什么?,上面的更新的都没错,插入数据就有错了!
asp中的代码如下:
[code=C#][/code] string strconn = Convert.ToString(ConfigurationManager.ConnectionStrings["ConnectionString"]);
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
SqlCommand cmd = new SqlCommand("insert_customer", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@customid", TextBox1.Text.Trim()));
cmd.Parameters.Add(new SqlParameter("@customname", TextBox2.Text.Trim()));
cmd.Parameters.Add(new SqlParameter("@customcharge", DropDownList1.Text.Trim()));
cmd.Parameters.Add(new SqlParameter("@customdesc", TextBox3.Text.Trim()));
cmd.Parameters.Add(new SqlParameter("@customlevel", DropDownList2.Text.Trim()));
cmd.ExecuteNonQuery();
Response.Redirect("Customers.aspx");
conn.Close();
明天就得交了,求大虾给解释下,初学asp,头快爆了!!!
[code=SQL][/code]ALTER PROCEDURE insert_customer
(
@customid [char] (10),
@customname [char] (10),
@customcharge [char] (10),
@customdesc [varchar] (100),
@customlevel [int]
)
AS
insert into [corporation].[dbo].[customer]
(
[CustomID],
[CustomName],
[CustomCharge],
[CustomDesc],
[CustomLevel]
)
values
(
@customid,
@customname,
@customcharge,
@customdesc,
@customlevel
)
RETURN
asp中的代码就不贴了,
再看下出错的,很不解:
[code=SQL][/code]ALTER PROCEDURE update_customer
(
@customid [char] (10),
@oldcustomid [char] (10),
@customname [char] (10),
@customcharge [char] (10),
@customdesc [varchar] (100),
@customlevel [int]
)
AS
update [corporation].[dbo].[customer]
set
[CustomID] = @customid,
[CustomName] = @customname,
[CustomCharge] = @customcharge,
[CustomDesc] = @customdesc,
[CustomLevel] = @customlevel
where
(CustomID = @oldcustomid)
RETURN
报错说[corporation].[dbo].[customer]对象名无效,为什么?,上面的更新的都没错,插入数据就有错了!
asp中的代码如下:
[code=C#][/code] string strconn = Convert.ToString(ConfigurationManager.ConnectionStrings["ConnectionString"]);
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
SqlCommand cmd = new SqlCommand("insert_customer", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@customid", TextBox1.Text.Trim()));
cmd.Parameters.Add(new SqlParameter("@customname", TextBox2.Text.Trim()));
cmd.Parameters.Add(new SqlParameter("@customcharge", DropDownList1.Text.Trim()));
cmd.Parameters.Add(new SqlParameter("@customdesc", TextBox3.Text.Trim()));
cmd.Parameters.Add(new SqlParameter("@customlevel", DropDownList2.Text.Trim()));
cmd.ExecuteNonQuery();
Response.Redirect("Customers.aspx");
conn.Close();
明天就得交了,求大虾给解释下,初学asp,头快爆了!!!
作者: opqm2009 发布时间: 2011-12-12
insert是插入数据的,update是更新数据的,你好像说反了,到底哪个有问题
作者: ssp2009 发布时间: 2011-12-12
对对,是我说反了,copy是没注意,是insert有问题,更新没有问题
作者: opqm2009 发布时间: 2011-12-12
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28