R
rob merritt
I have a function that on page load iterate through a
OleDbDataReader this works with a simple query like
SELECT * FROM TeachingExp WHERE (TeachingExp.UserId_fk='" +
Session["UserName"] + "')"
but with a more complicated query
SELECT * FROM TeachingExp, TeacherPrefs, SubExp, References,
personalData, EduHistory, EduEquity, CriminalRecord, Comments,
Certification
WHERE (TeachingExp.UserId_fk='"+Session["UserName"]+"' and
TeacherPrefs.UserId_fk='"+Session["UserName"]+"' and
SubExp.UserId_fk='"+Session["UserName"]+"'
and References.UserId_fk='"+Session["UserName"]+"' and
personalData.UserId_fk='"+Session["UserName"]+"' and
EduHistory.UserId_fk='"+Session["UserName"]+"'
and EduEquity.UserId_fk='"+Session["UserName"]+"' and
CriminalRecord.UserId_fk='"+Session["UserName"]+"' and
Comments.UserId_fk='"+Session["UserName"]+"'
and Certification.UserId_fk='"+Session["UserName"]+"')";
void Fill_Session_Vars()
{
string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\WebSites\\appForm\\data\\ASPNetDB.mdb";
OleDbConnection cn = new OleDbConnection(connectString);
cn.Open();
string selectString = "SELECT * FROM TeachingExp, TeacherPrefs,
SubExp, References, personalData, EduHistory, EduEquity,
CriminalRecord, Comments, Certification
WHERE (TeachingExp.UserId_fk='"+Session["UserName"]+"' and
TeacherPrefs.UserId_fk='"+Session["UserName"]+"' and
SubExp.UserId_fk='"+Session["UserName"]+"'
and References.UserId_fk='"+Session["UserName"]+"' and
personalData.UserId_fk='"+Session["UserName"]+"' and
EduHistory.UserId_fk='"+Session["UserName"]+"'
and EduEquity.UserId_fk='"+Session["UserName"]+"' and
CriminalRecord.UserId_fk='"+Session["UserName"]+"' and
Comments.UserId_fk='"+Session["UserName"]+"'
and Certification.UserId_fk='"+Session["UserName"]+"')";
//this works string selectString = "SELECT * FROM TeachingExp
WHERE (TeachingExp.UserId_fk='" + Session["UserName"] + "')";
try
{
OleDbCommand cmd = new OleDbCommand(selectString, cn);
OleDbDataReader reader = cmd.ExecuteReader();
int i = 0;
while (reader.Read())
{
Response.Write(reader.ToString() + "<br>");
i++;
}
reader.Close();
cn.Close();
}
catch (Exception ex)
{
Response.Write("<br>"+selectString);
Response.Write("<br>"+ex);
}
}
HERE IS THE ERROR:
SELECT * FROM TeachingExp, TeacherPrefs, SubExp, References,
personalData, EduHistory, EduEquity, CriminalRecord, Comments,
Certification WHERE (TeachingExp.UserId_fk='merrittr' and
TeacherPrefs.UserId_fk='merrittr' and SubExp.UserId_fk='merrittr' and
References.UserId_fk='merrittr' and personalData.UserId_fk='merrittr'
and EduHistory.UserId_fk='merrittr' and EduEquity.UserId_fk='merrittr'
and CriminalRecord.UserId_fk='merrittr' and
Comments.UserId_fk='merrittr' and Certification.UserId_fk='merrittr')
Syntax error in FROM clause.
OleDbDataReader this works with a simple query like
SELECT * FROM TeachingExp WHERE (TeachingExp.UserId_fk='" +
Session["UserName"] + "')"
but with a more complicated query
SELECT * FROM TeachingExp, TeacherPrefs, SubExp, References,
personalData, EduHistory, EduEquity, CriminalRecord, Comments,
Certification
WHERE (TeachingExp.UserId_fk='"+Session["UserName"]+"' and
TeacherPrefs.UserId_fk='"+Session["UserName"]+"' and
SubExp.UserId_fk='"+Session["UserName"]+"'
and References.UserId_fk='"+Session["UserName"]+"' and
personalData.UserId_fk='"+Session["UserName"]+"' and
EduHistory.UserId_fk='"+Session["UserName"]+"'
and EduEquity.UserId_fk='"+Session["UserName"]+"' and
CriminalRecord.UserId_fk='"+Session["UserName"]+"' and
Comments.UserId_fk='"+Session["UserName"]+"'
and Certification.UserId_fk='"+Session["UserName"]+"')";
void Fill_Session_Vars()
{
string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\\WebSites\\appForm\\data\\ASPNetDB.mdb";
OleDbConnection cn = new OleDbConnection(connectString);
cn.Open();
string selectString = "SELECT * FROM TeachingExp, TeacherPrefs,
SubExp, References, personalData, EduHistory, EduEquity,
CriminalRecord, Comments, Certification
WHERE (TeachingExp.UserId_fk='"+Session["UserName"]+"' and
TeacherPrefs.UserId_fk='"+Session["UserName"]+"' and
SubExp.UserId_fk='"+Session["UserName"]+"'
and References.UserId_fk='"+Session["UserName"]+"' and
personalData.UserId_fk='"+Session["UserName"]+"' and
EduHistory.UserId_fk='"+Session["UserName"]+"'
and EduEquity.UserId_fk='"+Session["UserName"]+"' and
CriminalRecord.UserId_fk='"+Session["UserName"]+"' and
Comments.UserId_fk='"+Session["UserName"]+"'
and Certification.UserId_fk='"+Session["UserName"]+"')";
//this works string selectString = "SELECT * FROM TeachingExp
WHERE (TeachingExp.UserId_fk='" + Session["UserName"] + "')";
try
{
OleDbCommand cmd = new OleDbCommand(selectString, cn);
OleDbDataReader reader = cmd.ExecuteReader();
int i = 0;
while (reader.Read())
{
Response.Write(reader.ToString() + "<br>");
i++;
}
reader.Close();
cn.Close();
}
catch (Exception ex)
{
Response.Write("<br>"+selectString);
Response.Write("<br>"+ex);
}
}
HERE IS THE ERROR:
SELECT * FROM TeachingExp, TeacherPrefs, SubExp, References,
personalData, EduHistory, EduEquity, CriminalRecord, Comments,
Certification WHERE (TeachingExp.UserId_fk='merrittr' and
TeacherPrefs.UserId_fk='merrittr' and SubExp.UserId_fk='merrittr' and
References.UserId_fk='merrittr' and personalData.UserId_fk='merrittr'
and EduHistory.UserId_fk='merrittr' and EduEquity.UserId_fk='merrittr'
and CriminalRecord.UserId_fk='merrittr' and
Comments.UserId_fk='merrittr' and Certification.UserId_fk='merrittr')
Syntax error in FROM clause.