public class Chotel
{
public Chotel()
{
//
// TODO: 在此处添加构造函数逻辑
//
    }
    #region  var
    private string str_number;
    #endregion
    #region property
    public string number
    {
        get { return str_number; }
        set { str_number = value; }
    }
    #endregion
    #region method
    public int add(DBSQL sql)
    {
        try
        {
            return sql.sqlCommand("insert into hotel values('" + number + "')");
        }
        catch (Exception ex)
        {
            throw (ex);
        
        }
    
    }
    public int update(DBSQL sql)
    {
        try
        {
            return sql.sqlCommand("update hotel set hnumber='" + number + "'");
        }
        catch (Exception ex)
        {
            throw ex; 
        }
    
    }
    public int delete(DBSQL sql)
    {
        try
        {
            return sql.sqlCommand("delete from hotel where hunmber='" + number + "'");
        }
        catch (Exception ex)
        {
            throw (ex); 
        }
    
    }
    public static DataTable select(DBSQL sql, string Condition)
    {
        try
        {  DataTable  dt=new DataTable();
            if (Condition.Trim()== "")
            {
               dt= sql.dbToDS("select * from hotel where", "temp").Tables["temp"];
            }
            else dt=sql.dbToDS("select * from hotel where"+Condition, "temp").Tables["temp"];
        if(dt.Rows.Count>0)
        {
        return dt;
        }
        else return null;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
#endregion
}

解决方案 »

  1.   

    看下这个DbHelper类http://blog.csdn.net/zhoukang0916/archive/2009/10/25/4726148.aspx
      

  2.   

    看了看,眼拙,提出两点,也不一定算是错误,LZ看能不能再斟酌斟酌1.return sql.sqlCommand("insert into hotel values('" + number + "')"); 
    这里的[color=#FF0000]number建议换成str_number,要不然str_number没用任何意义。[/color]2.if (Condition.Trim()== "") 
           { 
             dt= sql.dbToDS("select * from hotel where", "temp").Tables["temp"]; 
           } select * from hotel where
    本人眼拙,这里的"where"是不是要去掉,如果留在上面,SQL语句应该是错误的吧。