hi..I use sqlserver2005 as backend in my C# application i write following query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Surajrepe7
    New Member
    • Jan 2012
    • 1

    hi..I use sqlserver2005 as backend in my C# application i write following query

    "insert into stud_Exam_Recor d(PRN,Roll_no,F irst_name,Last_ Name,UN1_Total, UN2_Total,Final _total,Final_Ou tof,Percentage) values('" + textBox1.Text + "','" + textBox2.Text + "'," + textBox3.Text + "," + textBox4.Text + ",'" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "') ";
    but i face error "The name "fsdgf" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted." data type of First_name is ntext ,please help me
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You need to enclose all text fields in single quotes. For some reason, you do it for all your fields except first and last name. So it's obvious you know you have to do so, but you probably just missed those two.

    Comment

    Working...