缺少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;
}
}
}