| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3384 人关注过本帖
标题:sqlhelper调用问题
只看楼主 加入收藏
黑夜轮回
Rank: 2
等 级:论坛游民
帖 子:16
专家分:18
注 册:2016-9-3
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
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
lukebc
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:3
帖 子:74
专家分:32
注 册:2009-8-18
收藏
得分:7 
调用方法啊
2016-11-04 15:36
向洪林
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:重庆市奉节县
等 级:版主
威 望:9
帖 子:118
专家分:405
注 册:2015-3-10
收藏
得分:7 
自己封装sqlHelperL类吧,在sqlHelper类当中自己封装各种方法

新手上路,望大家多多照顾,谢谢!
2016-11-08 13:45
快速回复:sqlhelper调用问题
数据加载中...
 
   



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

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