标题: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;
        }

    }
}
搜索更多相关主题的帖子: database private public 
2016-11-02 08:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-470599-1-1.html




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

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