请高手帮忙看看我这个库房管理系统的录入功能模块 我中不到哪出问题 谢谢
我先发后台的程序代码(如下):using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data;
public partial class material_come : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd;
SqlTransaction tr;
SqlParameter pm1;
SqlParameter pm2;
SqlParameter pm3;
SqlParameter pm4;
SqlParameter pm5;
SqlParameter pm6;
SqlParameter pm7;
SqlParameter pm8;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button3_Click(object sender, EventArgs e)
{
if (Page.IsValid == true)
{
con = conn.conn1();
try
{
con.Open();
tr = con.BeginTransaction();
cmd = new SqlCommand("addmaterial",con);
cmd.CommandType = CommandType.StoredProcedure;
pm1=new SqlParameter("@material_typename", SqlDbType.VarChar);
pm2 = new SqlParameter("@material_name", SqlDbType.VarChar);
pm3 = new SqlParameter("@material_unit", SqlDbType.VarChar);
pm4 = new SqlParameter("@material_onemoney", SqlDbType.Decimal);
pm5 = new SqlParameter("@material_comecount", SqlDbType.Int);
pm6 = new SqlParameter("@material_allcomemoney", SqlDbType.Decimal);
pm7 = new SqlParameter("@material_sourcename", SqlDbType.VarChar);
pm8 = new SqlParameter("@material_cometime", SqlDbType.DateTime);
pm1.Value = txtMaterial_type.Text.Trim();
pm2.Value = txtmaterial_name.Text.Trim();
pm3.Value = txtmaterial_unit.Text.Trim();
pm4.Value = txtmaterial_onemoney.Text.Trim();
pm5.Value = txtmaterial_count.Text.Trim();
pm6.Value = txtmaterial_allmoney.Text.Trim();
pm7.Value = txtmaterial_source.Text.Trim();
String str = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day;
pm8.Value = str.Trim();
tr.Commit();
}
catch
{
Response.Write("插入数据失败~!");
tr.Rollback();
}
finally
{
con.Close();
}
}
}
}
下边是存储过程的:
alter proc addmaterial
@material_typename varchar,
@material_name varchar,
@material_unit varchar,
@material_onemoney dec,
@material_comecount int,
@material_allcomemoney dec,
@material_sourcename varchar,
@material_cometime datetime
as
declare @material_typeid int
declare @material_id int
declare @material_sourceid int
declare @material_comecount1 int
declare @strsql1 varchar(200)
declare @strsql2 varchar(200)
declare @strsql3 varchar(200)
declare @strsql4 varchar(200)
declare @strsql5 varchar(200)
declare @strsql6 varchar(200)
declare @strsql7 varchar(200)
declare @strsql8 varchar(200)
set @strsql1='insert into materialtype_name values('+@material_typename+')'
set @strsql2='select' +@material_typeid+'=material_typeid from material_type where materialtype_name='+@material_typename
set @strsql3='insert into material_save(material_typeid,material_name,material_unit) values('+@material_typeid+','+@material_name+','+@material_unit+')'
set @strsql4='select '+ @material_id+'=material_id from material_save where material_name='+@material_name
set @strsql5='insert into material_comesource values('+@material_sourcename+')'
set @strsql6='select '+@material_sourceid+'=material_sourceid from material_comesource where material_sourcename='+@material_sourcename
set @strsql7='insert into material_come values('+@material_typeid+','+@material_id+','+@material_onemoney+','+@material_comecount+','+@material_allcomemoney+','+@material_unit+','+@material_sourceid+','+@material_cometime+')'
set @strsql8='update material_save set material_allcount=material_allcount+'+@material_comecount1+' where material_id='+@material_id
exec(@strsql1)
exec(@strsql2)
exec(@strsql3)
exec(@strsql4)
exec(@strsql5)
exec(@strsql6)
exec(@strsql7)
exec(@strsql7)
go
我在程序中执行异常不抛出来 无任何反映 点完按钮 后到数据库中值也没进去 我怀疑是不是存储过程写的有问题 但有找不到 有没有高手能指点下啊 我是个菜鸟 积分也不是很多 就这点贡献给大家了
--------------------编程问答-------------------- 存储过程也可以在查询分析器里调试的,你调试个看看 --------------------编程问答-------------------- 2005中的"服务器资源管理器"中也可以调试存储过程,
没细看,发现引号有问题,给你个例子,调试通过的,
declare @sqlStr varchar(1024)
declare @conditionStr varchar
set @conditionStr = 'p'
set @sqlStr = 'select top 10 * from MSPetShop4..item where status = '''+ @conditionStr +''''
exec(@sqlStr)
春节还工作啊,,,,呵呵,加油,新年愉快 --------------------编程问答-------------------- 我怎么没有看到执行的语句啊,还有参数没有添加到CMD里面 --------------------编程问答-------------------- exec(@strsql1)
exec(@strsql2)
exec(@strsql3)
exec(@strsql4)
exec(@strsql5)
exec(@strsql6)
exec(@strsql7)
exec(@strsql7)
?????什么语法,不是存储过程啊...
alter proc addmaterial
////////你这下面所有的全是声明变量啊,存储过程体里也是赋值字符串变量啊,建议看看存储过程...
@material_typename varchar,
@material_name varchar,
@material_unit varchar,
@material_onemoney dec,
@material_comecount int,
@material_allcomemoney dec,
@material_sourcename varchar,
@material_cometime datetime
as
declare @material_typeid int
declare @material_id int
declare @material_sourceid int
declare @material_comecount1 int
declare @strsql1 varchar(200)
declare @strsql2 varchar(200)
declare @strsql3 varchar(200)
declare @strsql4 varchar(200)
declare @strsql5 varchar(200)
declare @strsql6 varchar(200)
declare @strsql7 varchar(200)
declare @strsql8 varchar(200)
set @strsql1='insert into materialtype_name values('+@material_typename+')'
set @strsql2='select' +@material_typeid+'=material_typeid from material_type where materialtype_name='+@material_typename
set @strsql3='insert into material_save(material_typeid,material_name,material_unit) values('+@material_typeid+','+@material_name+','+@material_unit+')'
set @strsql4='select '+ @material_id+'=material_id from material_save where material_name='+@material_name
set @strsql5='insert into material_comesource values('+@material_sourcename+')'
set @strsql6='select '+@material_sourceid+'=material_sourceid from material_comesource where material_sourcename='+@material_sourcename
set @strsql7='insert into material_come values('+@material_typeid+','+@material_id+','+@material_onemoney+','+@material_comecount+','+@material_allcomemoney+','+@material_unit+','+@material_sourceid+','+@material_cometime+')'
set @strsql8='update material_save set material_allcount=material_allcount+'+@material_comecount1+' where material_id='+@material_id
exec(@strsql1)
补充:.NET技术 , ASP.NET