【发布时间】:2018-07-05 19:46:05
【问题描述】:
我在数据库中有一个 SQL 表,其中有一列具有 Bit 数据类型。我试图在我的 C# 应用程序中定义一个方法,该方法从表中获取两列并将它们用作参数。
这里是代码
public void Edit_NAA_ApplicationsFirm(int ApplicationId, string UniversityOffer, bit Firm)
{
//This line declares a variable in which we store the actual values from NAA_Applications based on the associating ID
NAA_Applications AppFirm = Get_Applicant_Application(ApplicationId);
//Here we tell the application that the values edited are equal to the values within the table
AppFirm.Firm = Firm;
//Any of these changes are then saved.
_context.SaveChanges();
}
唯一的问题是程序不断尝试将位转换为 BitConverter。当我将其更改为 bit 时,将其作为数据类型接受时会出现问题。
值得注意的是,我在 ASP.Net 框架解决方案中构建应用程序。
谁能告诉我我做错了什么?我只是指的数据类型错误吗?
【问题讨论】:
-
您使用的是哪个 dbms? (ANSI SQL 没有位数据类型。)
-
我不确定管理服务是什么,我们通过 Visual Studio 中的服务器连接来连接它
-
如果使用sql server,bit可以映射到C# bool。
-
public void Edit_NAA_ApplicationsFirm(int ApplicationId, string UniversityOffer, bool Firm)
标签: c# sql asp.net sql-server tsql