日期:2014-05-18  浏览次数:20919 次

SqlHelper并不包含“ConnectionString”的定义
from1错误行为:SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.Text, sql);
以下为sqlhelper.cs代码内含有ExecuteNonQuery的代码
  public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
  {

  SqlCommand cmd = new SqlCommand();

  using (SqlConnection conn = new SqlConnection(connectionString))
  {
  PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
  int val = cmd.ExecuteNonQuery();
  cmd.Parameters.Clear();
  return val;
  }
  }

  public static int ExecuteNonQuery(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
  {

  SqlCommand cmd = new SqlCommand();

  PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
  int val = cmd.ExecuteNonQuery();
  cmd.Parameters.Clear();
  return val;
  }

  public static int ExecuteNonQuery(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
  {
  SqlCommand cmd = new SqlCommand();
  PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters);
  int val = cmd.ExecuteNonQuery();
  cmd.Parameters.Clear();
  return val;
  }

------解决方案--------------------
查下代码,看看你的SQLHelper类的ConnectionString属性,没有 自己填一个
------解决方案--------------------
C# code
public string ConnectionString{get;set;}

------解决方案--------------------
探讨

怎么添加啊?能给一个简单的添加过程吗?偶是菜鸟

------解决方案--------------------
楼上的非常正确