| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 497 人关注过本帖
标题:新人求大婶帮忙,代码出现问题
只看楼主 加入收藏
gc391462165
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2014-5-14
收藏
 问题点数:0 回复次数:1 
新人求大婶帮忙,代码出现问题
namespace WebApplication1.cs
{
   
        /// <summary>
        ///
        /// </summary>
        sealed internal class StoredProcedure : IDisposable {
            public string ErrorMessage = "";
            private System.Data.SqlClient.SqlCommand command;
            public StoredProcedure(string sqlText){
                ConfigManager config =new ConfigManager();
                command = new SqlCommand(sqlText, new SqlConnection(config.DALConnectionString));
               
                command.Connection.Open();}
            /// <summary>
            ///
            /// </summary>
            public void Dispose(){
                if(command!=null)
                {
                SqlConnection connection=command.Connection;
                Debug.Assert(connection!=null);
                command.Dispose();
                command=null;
                connection.Dispose();
                }
            }
            /// <summary>
            /// <returns></returns>
            /// </summary>
            public int Run()
            {
                if (command != null)
                {
                    throw new ObjectDisposedException(GetType().FullName);
                    try
                    {
                        command.ExecuteNonQuery();
                        return 1;
                    }
                    catch (Exception e)
                    {
                        ErrorMessage = e.Message;
                        return 0;
                    }
                }
            }
            /// <summary>
            ///
            /// </summary>
            /// <param name="dataTable"></param>
            /// <returns></returns>

            public int Run(DataTable dataTable){
                if(command==null)
                    throw new ObjectDisposedException(GetType().FullName);
                try{
                    SqlDataAdapter dataAdapter =new SqlDataAdapter();
                    dataAdapter.SelectCommand= command;
                    dataAdapter.Fill(dataTable);
                    return 1;
                }
                catch(Exception e){
                    ErrorMessage=e.Message;
                    return 0;
                }
            }

        }

run()部分显示不是所以数据有返回值,try部分显示无法访问代码,求教怎么该
搜索更多相关主题的帖子: command private public sealed 
2014-05-14 13:06
gc391462165
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2014-5-14
收藏
得分:0 
是大神!~标题打错了!~
2014-05-14 13:07
快速回复:新人求大婶帮忙,代码出现问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020412 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved