私は以下のコードを持っています、そして私はこのエラーを受け取ります:
Troubleshooting Exceptions: System.Data.OleDb.OleDbException "syntax error"
何を間違えたのかわかりません。テーブルから情報を取得することを想定しています。プロジェクト全体で同じ方法を使用しましたが、これだけでは問題が発生します...
class Codons
{
private bool start, end;
private string codon1, codon3, triplet1, triplet2, triplet3;
private string triplet4, triplet5, triplet6, fullName;
private OleDbConnection dataconnection;
public Codons(string letter)
{
this.start = false;
this.end = false;
this.dataconnection = new OleDbConnection();
this.dataconnection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Projects_2012\\Project_Noam\\Access\\myProject.accdb";
this.dataconnection.Open();
string sql = "SELECT tblCodons.codonsCodon3, " +
"tblCodons.codonsTriplet1, tblCodons.codonsTriplet2, tblCodons.codonsTriplet3, " +
"tblCodons.codonsTriplet4, tblCodons.codonsTriplet5, tblCodons.codonsTriplet6, " +
"tblCodons.codonsFullName, tblCodons.codonsStart, tblCodons.codonsEnd"
+ " FROM tblCodons"
+ " WHERE tblCodons.codonsCodon1="+letter;
OleDbCommand mycomm = new OleDbCommand(sql, dataconnection);
OleDbDataReader dataReader = mycomm.ExecuteReader();
dataReader.Read();
this.codon1 = letter;
this.codon3 = dataReader.GetString(0);
this.triplet1 = dataReader.GetString(1);
if (dataReader.IsDBNull(2))
this.triplet2 = " ";
else
this.triplet2 = dataReader.GetString(2);
if (dataReader.IsDBNull(3))
this.triplet3 = " ";
else
this.triplet3 = dataReader.GetString(3);
if (dataReader.IsDBNull(4))
this.triplet4 = " ";
else
this.triplet4 = dataReader.GetString(4);
if (dataReader.IsDBNull(5))
this.triplet5 = " ";
else
this.triplet5 = dataReader.GetString(5);
if (dataReader.IsDBNull(6))
this.triplet6 = " ";
else
this.triplet6 = dataReader.GetString(6);
this.fullName = dataReader.GetString(7);
this.start = dataReader.GetBoolean(8);
this.end = dataReader.GetBoolean(9);
dataReader.Close();
}