当我尝试使用此查询访问数据库时,它会给我一个错误
invalid column name 'sandeep' which is the name of the patient ie itemArray[3]
代码:
case "patient":
string queryPatientCheck = @"select *
from patient
where
[patientID]={0} and
[patientName]={1}";
queryPatientCheck = string.Format(queryPatientCheck, itemArray[2], itemArray[3]);
答案 0 :(得分:3)
你的sql翻译成这个
select *
from patient
where
[patientID]={0} and
[patientName]=sandeep
在这种情况下,它会搜索名为sandeep的列。你想要的是字符串sandeep,'sandeep'
select *
from patient
where
[patientID]={0} and
[patientName]='sandeep'