先说一个没有问题的,是更新数据的,存储过程为
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中的代码就不贴了,
再看下出错的,很不解:
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中的代码如下:
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,头快爆了!!!
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中的代码就不贴了,
再看下出错的,很不解:
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中的代码如下:
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,头快爆了!!!
直接在数据库里执行有问题吗?