| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 3696 人关注过本帖
标题:sqlhelper调用问题
取消只看楼主 加入收藏
黑夜轮回
Rank: 2
等 级:论坛游民
帖 子:16
专家分:18
注 册:2016-9-3
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:0 
sqlhelper调用问题
我需要在aspx.cs中引用sqlhelper
需要怎么么处理啊

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using _123;

namespace _123
{
    public class SqlHelper
    {
        private String connectionString = "Server=.;database=c;uid=sa;pwd=123";

        public SqlDataReader ExecuteReader(String sql)
        {
            SqlConnection connection = new SqlConnection(connectionString);

            connection.Open();

            SqlCommand command = new SqlCommand(sql, connection);

            SqlDataReader result = command.ExecuteReader();

            return result;
        }

        public bool ExecuteCommand(String sql)
        {
            bool result = false;

            try
            {
                SqlConnection connection = new SqlConnection(connectionString);
                connection.Open();

                SqlCommand command = new SqlCommand(sql, connection);
                //command.Connection = connection;
                // = sql;
                command.ExecuteNonQuery();


                connection.Close();

                result = true;
            }
            catch (Exception e)
            {
                throw e;
            }

            return result;
        }

    }
}
2016-11-02 08:56
快速回复:sqlhelper调用问题
数据加载中...
 
   



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

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026849 second(s), 11 queries.
Copyright©2004-2025, BC-CN.NET, All Rights Reserved