读书人

请问关于调用存款过程的有关问题,小弟

发布时间: 2012-01-30 21:15:58 作者: rapoo

请教关于调用存款过程的问题,我是直接是用SQL语句写的,总是出现问题,只有10分了!万分感谢!
string connectionstring = ConfigurationManager.ConnectionStrings[ "nbmisConnectionString "].ConnectionString;
SqlConnection con = new SqlConnection(connectionstring);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;

sql = "exec CP_Manage '20061101 ', '20061231 ', '1 ', ' ', ' ' ";

cmd.CommandText = sql;
con.Open();
this.GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
con.Close();
con.Dispose();

问题出现:
超时时间已到。在操作完成之前超时时间已过或服务器未响应。
this.GridView1.DataSource = cmd.ExecuteReader();
总是这一行不对,
如果我把sql改为常用的select 语句就没有问题,
我这个存储过程是一个很复杂的查询语句,直接在查询分析里执行没有任何问题,只有5秒左右就会出现结果
create PROCEDURE CP_Manage
@stdt char(8),
@eddt char(8),
@flag char(1),
@dept_id varchar(10),
@empl_id varchar(10)
AS
SET NOCOUNT ON
select * from c_manage

多谢!

[解决办法]
SqlConnection Conn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings[ "ConnectionString "]);
Conn.Open();
SqlDataAdapter Da=new SqlDataAdapter( "exec CP_Manage '20061101 ', '20061231 ', '1 ', ' ', ' ' ",Conn);
DataSet t_ds=new DataSet();
Da.Fill(t_ds,tablename);
Da.Dispose();
Conn.Close();
Conn.Dispose();

[解决办法]
tablename 填充DataSet里DataTable 的名字

[解决办法]
将你那个过程东西简化,变成多个简单的过程。
[解决办法]
public DataSet Ds(string s_tmp,string tablename)
{
SqlConnection Conn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings[ "ConnectionString "]);
Conn.Open();
SqlDataAdapter Da=new SqlDataAdapter(s_tmp,Conn);
DataSet t_ds=new DataSet();
Da.Fill(t_ds,tablename);
Da.Dispose();
Conn.Close();
Conn.Dispose();
return t_ds;
}

调用
DataSet ds=new DataSet();

ds=Ds( "exec CP_Manage '20061101 ', '20061231 ', '1 ', ' ', ' ' ", "table1 ");
this.GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();


[解决办法]
string connectionstring = ConfigurationManager.ConnectionStrings[ "nbmisConnectionString "].ConnectionString;


SqlConnection con = new SqlConnection(connectionstring);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;///

sql = "exec CP_Manage '20061101 ', '20061231 ', '1 ', ' ', ' ' ";///

我晕,调用存储过程能这样调吗????
应该改成:
cmd.CommandText = "CP_Manager ";
cmd.CommandType = CommandType.storedProcedure;
cmd.Parameters.AddWithValue( "参数名称 ",参数值);
cmd.Parameters.AddWithValue( "参数名称 ",参数值);
cmd.Parameters.AddWithValue( "参数名称 ",参数值);
.
.
.
con.Open();
this.GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
con.Close();
con.Dispose();

读书人网 >asp.net

热点推荐