标题:缺少using指令或程序集引用 怎么改啊 小弟是个新手!请高手们指教!
只看楼主
wangda09
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-8-22
结帖率:0
已结贴  问题点数:20 回复次数:3 
缺少using指令或程序集引用 怎么改啊 小弟是个新手!请高手们指教!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace DAL
{
    public class SQLHelper
    {
        /// <summary>
        /// 该方法执行传入的增删改SQL语句
        /// </summary>
        /// <param name="sql">要执行的SQL语句</param>
        /// <returns>返回更新的记录数</returns>
        public static  int ExecuteNonQuery(string sql)
        {
            string connStr = @"server=sqlexpress;database=newssystem;uid=Adam";
            SqlConnection conn = new SqlConnection(connStr);
            conn.Open();
            string sq = "insert into category(name) values('news')";
            SqlCommand cmd = new SqlCommand(sql.conn
);
            int res = cmd.ExecuteNonQuery();
            conn.Close();
            return res;

        }
        /// <summary>
        /// 该方法执行传入的SQL查询语句
        /// </summary>
        /// <param name="sql">SQL查询语句</param>
        /// <returns></returns>
        public static  DataTable ExecuteQuery(string sql)
        {
            DataTable dt = new DataTable();
            string connStr = @"server=sqlexpress;database=newssystem;uid=Adam";
            SqlConnection conn = new SqlConnection(connStr);
            conn.Open();
            string sq= "insert into category(name) values('news')";
            SqlCommand cmd = new SqlCommand(sql.conn);
            SqlDataReader sdr=cmd .ExecuteReader ();
            dt.Load(sdr);
            sdr.Close();
            conn.Close();
            return dt;
        }
    }
}
搜索更多相关主题的帖子: using 指令 
2010-08-22 17:52
一样的梦_涛
Rank: 2
等 级:论坛游民
帖 子:4
专家分:17
注 册:2010-8-13
得分:6 
SqlCommand cmd = new SqlCommand(sql,conn);
应该用逗号,
string sq= "insert into category(name) values('news')";//这个好像没用到
2010-08-25 18:31
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
得分:6 
string sql= "insert into category(name) values('news')";
SqlCommand cmd = new SqlCommand(sql, conn);

飘过~~
2010-08-25 18:47
one_june
Rank: 4
等 级:业余侠客
帖 子:139
专家分:212
注 册:2010-3-14
得分:6 
string sq= "insert into category(name) values('news')";
SqlCommand cmd = new SqlCommand(sql,conn);
怎么不一样呢?
2010-08-26 20:12



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




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

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