你好!我试图在Visual Basic c#中连接4个表格形式的Access,但出现“查询表达式中的语法错误(缺少运算符)”,请您帮我吗?谢谢!
string query = "Select e.Denumire_Ech, e.Descriere_Ech, e.UnitateMasura, e.Pret_Vanzare, o.Cantitate_EchOf From ECHIPAMENTE e INNER JOIN OFERTE o ON e.Cod_Echipament = o.Cod_Echipament INNER JOIN CONTRACTE c ON c.Cod_Oferta = o.Cod_Oferta INNER JOIN FACTURI f ON f.Nr_Contract = c.Nr_Contract WHERE Nr_Contract='" + CB_Contract.Text + "'";
答案 0 :(得分:1)
您有多个要联接的表,但未指定WHERE子句在哪个表上查找。
string query = "Select e.Denumire_Ech, e.Descriere_Ech, e.UnitateMasura, e.Pret_Vanzare, o.Cantitate_EchOf From ECHIPAMENTE e INNER JOIN OFERTE o ON e.Cod_Echipament = o.Cod_Echipament INNER JOIN CONTRACTE c ON c.Cod_Oferta = o.Cod_Oferta INNER JOIN FACTURI f ON f.Nr_Contract = c.Nr_Contract WHERE c.Nr_Contract='" + CB_Contract.Text + "'";
此外,您还应注意CB_Contract.Text
中的SQL注入和异常字符,例如,如果有'字符,则sql将失败。