调用存储过程错误
protectedvoidPage_Load(objectsender,EventArgse){try{DataTabledb=GetData(101010101);Re...
protected void Page_Load(object sender, EventArgs e)
{
try
{
DataTable db = GetData(101010101);
Response.Write(db.Rows.Count);
}
catch
{
throw;
}
}
protected DataTable GetData(int Id_ts_tab)
{
DataTable db;
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConDB"]);
con.Open();
SqlCommand cmd = new SqlCommand("GetRegex", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter("@Id_ts_tab", SqlDbType.Int);
param.Direction = ParameterDirection.Input;
param.Value = Id_ts_tab;
SqlDataAdapter adater = new SqlDataAdapter();
adater.SelectCommand = cmd;
DataSet ds = new DataSet();
adater.Fill(ds);
db = ds.Tables[0];
con.Close();
return db;
}
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER proc [dbo].[GetRegex] @Id_ts_tab int
as
select name,Regex from ts_craler_regex where id_ts_tab=@id_ts_tab
异常详细信息: System.Data.SqlClient.SqlException: 过程或函数 'GetRegex' 需要参数 '@Id_ts_tab',但未提供该参数。 展开
{
try
{
DataTable db = GetData(101010101);
Response.Write(db.Rows.Count);
}
catch
{
throw;
}
}
protected DataTable GetData(int Id_ts_tab)
{
DataTable db;
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConDB"]);
con.Open();
SqlCommand cmd = new SqlCommand("GetRegex", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter("@Id_ts_tab", SqlDbType.Int);
param.Direction = ParameterDirection.Input;
param.Value = Id_ts_tab;
SqlDataAdapter adater = new SqlDataAdapter();
adater.SelectCommand = cmd;
DataSet ds = new DataSet();
adater.Fill(ds);
db = ds.Tables[0];
con.Close();
return db;
}
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER proc [dbo].[GetRegex] @Id_ts_tab int
as
select name,Regex from ts_craler_regex where id_ts_tab=@id_ts_tab
异常详细信息: System.Data.SqlClient.SqlException: 过程或函数 'GetRegex' 需要参数 '@Id_ts_tab',但未提供该参数。 展开
展开全部
protected DataTable GetData(int Id_ts_tab)
{
DataTable db;
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConDB"]);
con.Open();
SqlCommand cmd = new SqlCommand("GetRegex", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter("@Id_ts_tab", SqlDbType.Int);
param.Direction = ParameterDirection.Input;
param.Value = Id_ts_tab;
cmd.Parameters.Add(param); //这里你没有
SqlDataAdapter adater = new SqlDataAdapter();
adater.SelectCommand = cmd;
DataSet ds = new DataSet();
adater.Fill(ds);
db = ds.Tables[0];
con.Close();
return db;
}
{
DataTable db;
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConDB"]);
con.Open();
SqlCommand cmd = new SqlCommand("GetRegex", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter param = new SqlParameter("@Id_ts_tab", SqlDbType.Int);
param.Direction = ParameterDirection.Input;
param.Value = Id_ts_tab;
cmd.Parameters.Add(param); //这里你没有
SqlDataAdapter adater = new SqlDataAdapter();
adater.SelectCommand = cmd;
DataSet ds = new DataSet();
adater.Fill(ds);
db = ds.Tables[0];
con.Close();
return db;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
最后一个
@id_ts_tab改成@Id_ts_tab
@id_ts_tab改成@Id_ts_tab
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
到底是id_ts_tab还是Id_ts_tab?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询