SQL Query Syntax Error

  • Thread starter Thread starter Deecrypt
  • Start date Start date
D

Deecrypt

Hi,
I hope Im posting in the right newsgroup. I am trying to insert the
result
of the below SQL query in my Access 2003 table. All the fields in this
table
are of type Number. I'm picking up the value of a dropdownlist box and

insert the relevant values in one row of the table.

if (painPresentComboBox.Text == "RUQ")
{
int painPresent = 301717006;
string assessmentID = assessmentNoTextBox.Text;
Convert.ToInt32(assessmentID);
string insertAssessmentData = "INSERT INTO
abdominalpainassessmentrecords (assessment_id, aap_key, concept_id,
attribute, value) VALUES ('" + assessmentID + "', '1', '21522001',
'363698007', '" + painPresent + "')";
OleDbCommand insertAssessment = new
OleDbCommand(insertAssessmentData, o);
insertAssessment.ExecuteNonQuery();
}


Please Help. Desperate beyond belief


Khurram
 
Deecrypt said:
I am trying to insert the
result
of the below SQL query in my Access 2003 table.

if (painPresentComboBox.Text == "RUQ")
{
int painPresent = 301717006;
string assessmentID = assessmentNoTextBox.Text;
Convert.ToInt32(assessmentID);
string insertAssessmentData = "INSERT INTO
abdominalpainassessmentrecords (assessment_id, aap_key, concept_id,
attribute, value) VALUES ('" + assessmentID + "', '1', '21522001',
'363698007', '" + painPresent + "')";
OleDbCommand insertAssessment = new
OleDbCommand(insertAssessmentData, o);
insertAssessment.ExecuteNonQuery();
}

Numeric values should not be in single quotes. Try:

string insertAssessmentData = "INSERT INTO
abdominalpainassessmentrecords (assessment_id, aap_key, concept_id,
attribute, value) VALUES (" + assessmentID + ", 1, 21522001,
363698007, " + painPresent + ")";

Jamie.

--
 
Thank you, Problem solved. although i also had to take out all the
field names too. Seems does not like field names if the entire row is
going to be populated.

cheers

Khurram
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top