Visual C#通用模块开发:后台管理员模块[2]

发表于:2008-04-25来源:作者:点击数: 标签:开发管理员后台Visualvisual
关键字:c#objCommand.CommandText += " AND USERS.NICKNAME LIKE @NICKNAME"; // 设置Sql语句参数类型 objCommand.Parameters.Add("USERNAME", SqlDbType.VarChar); objCommand.Parameters.Add("NICKNAME", SqlDbType.VarChar); // Sql语句参数赋值 objComma
关键字:c#objCommand.CommandText += " AND USERS.NICKNAME LIKE @NICKNAME";
            // 设置Sql语句参数类型
            objCommand.Parameters.Add("USERNAME", SqlDbType.VarChar);
            objCommand.Parameters.Add("NICKNAME", SqlDbType.VarChar);
            // Sql语句参数赋值
            objCommand.Parameters["USERNAME"].Value = "%" + tbxUserName.Text.Trim() + "%";
            objCommand.Parameters["NICKNAME"].Value = "%" + tbxNickName.Text.Trim() + "%";
            //这里使用DataAdapter和DataSet获取数据
    DataSet objDataset = new DataSet();
            SqlDataAdapter objAdapter = new SqlDataAdapter(objCommand);
            try
            {
                // 打开数据库连接
                if (objConnection.State == ConnectionState.Closed)
                {
                     objConnection.Open();
                }

原文转自:http://www.ltesting.net