Reputation: 1
when I try to access the database with this query it gives me an error
invalid column name 'sandeep' which is the name of the patient ie itemArray[3]
code:
case "patient":
string queryPatientCheck = @"select *
from patient
where
[patientID]={0} and
[patientName]={1}";
queryPatientCheck = string.Format(queryPatientCheck, itemArray[2], itemArray[3]);
Upvotes: 0
Views: 578
Reputation: 15579
well your sql translates to this
select *
from patient
where
[patientID]={0} and
[patientName]=sandeep
and in this case it searches for a column called sandeep. What you want is the string sandeep i.e 'sandeep'
select *
from patient
where
[patientID]={0} and
[patientName]='sandeep'
Upvotes: 3