Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无效的列名异常,即使列存在_C#_Sql - Fatal编程技术网

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}'
或者更好地使用参数。