小编Ale*_*nez的帖子

using语句中使用的类型必须可以隐式转换为'System.IDisposable'

我的代码中有一个错误列为:'DatabaseLayer':using语句中使用的类型必须可以隐式转换为'System.IDispsable'.

我试着查看MSDN和其他Stack Overflow问题,但我还没有解决错误.我在Visual Studio 2015中使用.NET Framework 4.5.1.

错误在第56行,但我在错误行上面评论过.以下是我文件中的代码:

public class UserDataAccessLayer : IDisposable
{
    public bool Create(string username, string pwd, string email)
    {
        bool retVal = false;
        SqlCommand sqlCmd = new SqlCommand("CreateUser");
        sqlCmd.CommandType = CommandType.StoredProcedure;
        sqlCmd.Parameters.AddWithValue("@Username", username);
        sqlCmd.Parameters.AddWithValue("@Pwd", pwd);
        sqlCmd.Parameters.AddWithValue("@Email", email);
        int result = new DatabaseLayer().ExecuteNonQuery(sqlCmd);
        if (result != Int32.MaxValue)
            retVal = true;

        return retVal;
    }

    public bool Create(string username, string pwd, string email, int roleId)
    {
        bool retVal = false;
        SqlCommand sqlCmd = new SqlCommand("CreateUser");
        sqlCmd.CommandType = CommandType.StoredProcedure;
        sqlCmd.Parameters.AddWithValue("@Username", …
Run Code Online (Sandbox Code Playgroud)

c# stored-procedures

3
推荐指数
1
解决办法
3万
查看次数

标签 统计

c# ×1

stored-procedures ×1