C# Oracle 表问题

标签 c# asp.net database oracle

当我尝试登录用户时,我的 ASP.NET 应用程序出现问题。问题是,当我尝试运行查询时,会抛出一个异常,提示故事名称无效。这是因为表名为 USER,它是 SQL 的一部分。

我无法更改表名。

        public bool LoginUser(string username, string password)
    { 
        //Database Connectie maken
        DBConnectionOpen();

        string query = @"SELECT NICKNAME, PASSWORD FROM " + "'USER'" + "WHERE NICKNAME = '" + username + "'";
        bool result = false;

        try
        {
            OracleCommand command = new OracleCommand(query, conn);
            OracleDataReader reader = command.ExecuteReader();
            Console.WriteLine("*Query Uitvoeren*");
            reader.Read();

            if (username + password == reader.GetString(0) + reader.GetString(1))
            {
                result = true;
            }
        }

        catch (Exception ex)
        {
            throw ex;
        }

        finally
        {
            conn.Close();
        }

        return result;    


    }

最佳答案

任何将表命名为“USER”的人都应该删除 db privs,但我认为您只需要在表名周围添加双引号:

select * from "USER" where ...

请注意,添加双引号时区分大小写,因此如果表名为 User,则需要“User”而不是“USER”

关于C# Oracle 表问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30716536/

相关文章:

html - 我应该使用哪种列类型来存储未知大小的 HTML?

c# - 将数据导出到具有固定长度记录的文本文件

C# - 切换泛型

c# - 返回错误答案的日期差异

c# - 如何在ajax日历扩展器中限制年份

asp.net - 尝试在返回的 ToList 中获取 Distinct() 和/或 GroupBy(...)

c# - EntityContainer 中未定义 EntitySet 'sproc_Forums_GetForumGroupByID'

php - 如何在wordpress插件开发中列出表格?

database - 在数据库中存储名称

c# - 使用大量对象,需要更好的(排序的)性能