gpt4 book ai didi

asp.net - 如何执行 SQL 语句?

转载 作者:行者123 更新时间:2023-12-02 12:28:26 24 4
gpt4 key购买 nike

我对编程很陌生,大部分都是自学的。希望有人能给我关于代码的建议。

基本上,我遇到的问题是我的 SQL 语句没有执行以从数据库检索数据。它只是使用 SELECT MemberOne FROM aspnet_Users WHERE MemberOne LIKE '_' 分配 userPermissionsOne。

非常感谢任何帮助。

userName = User.Identity.Name;  
userName = userName.ToUpper();
selectedUserName = betDropDownList.SelectedValue;
userPermissionsOne = "SELECT MemberOne FROM aspnet_Users WHERE MemberOne LIKE '___'";
userPermissionsTwo = "SELECT MemberTwo FROM aspnet_Users WHERE MemberTwo LIKE '___'";
userPermissionsThree = "SELECT MemberThree FROM aspnet_Users WHERE MemberThree LIKE '___'";

if (string.Compare(userName, selectedUserName, true) == 0 || User.IsInRole("Administrator"))
{
hinzufugenButton.Enabled = true;
loschenButton.Enabled = true;
bearbeitenButton.Enabled = true;
betDropDownList.Enabled = true;
}
else if (userName == "ENL")
{
if (string.Compare(userPermissionsOne, selectedUserName, true) == 0 ||
string.Compare(userPermissionsTwo, selectedUserName, true) == 0 ||
string.Compare(userPermissionsThree, selectedUserName, true) == 0)
{
hinzufugenButton.Enabled = true;
loschenButton.Enabled = true;
bearbeitenButton.Enabled = true;
}
else
{
hinzufugenButton.Enabled = false;
loschenButton.Enabled = false;
bearbeitenButton.Enabled = false;
betDropDownList.Enabled = false;
}
}

最佳答案

对于如何使用 .NET 执行 SQL 语句,您有很多选择。对于初学者来说,请阅读以下内容。这些是我在决定如何访问数据库时通常考虑的前三种技术:

来自微软:

ADO.NET provides the most direct method of data access within the .NET Framework. For a higher-level abstraction that allows applications to work against a conceptual model instead of the underlying storage model, see the ADO.NET Entity Framework.

最近,我的数据库访问首选技术是 Dapper。它快速、轻量级且易于编码。

关于asp.net - 如何执行 SQL 语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9005430/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com