C# 无效的列名异常,即使列存在
当我尝试使用此查询访问数据库时,它会给我一个错误C# 无效的列名异常,即使列存在,c#,sql,C#,Sql,当我尝试使用此查询访问数据库时,它会给我一个错误 invalid column name 'sandeep' which is the name of the patient ie itemArray[3] 代码: 您的sql转换为 select * from patient where [patientID]={
invalid column name 'sandeep' which is the name of the patient ie itemArray[3]
代码:
您的sql转换为
select *
from patient
where
[patientID]={0} and
[patientName]=sandeep
在本例中,它搜索一个名为sandeep的列。您需要的是字符串sandeep,即'sandeep'
select *
from patient
where
[patientID]={0} and
[patientName]='sandeep'
您的sql转换为
select *
from patient
where
[patientID]={0} and
[patientName]=sandeep
在本例中,它搜索一个名为sandeep的列。您需要的是字符串sandeep,即'sandeep'
select *
from patient
where
[patientID]={0} and
[patientName]='sandeep'
试试
[patientName]='{1}'
或者更好地使用参数。试试[patientName]='{1}'
或者更好地使用参数。