嗨,我有以下三个表
我想获得用户通过的课程的 AGPA
我使用了这个 SQL 语法
string queryString =
"select R.mark, c.NumberOfCredits
from Courses c, RegisteredIn R
where R.CourseId=c.id and R.StudentId=StudentId and
R.mark > 60 R.mark themark,c.NumberOfCredits credit
select (sum(themark*credit)/sum(credit))*0.04 AGPA ";
我这样做是为了打印出结果
using (SqlConnection connection = new SqlConnection(connectionString)){
SqlCommand command = new SqlCommand(queryString, connection);
connection.Open();
System.Data.SqlClient.SqlDataReader reader = command.ExecuteReader();
reader.Read();
result = string.Empty;
_AGPA = reader[3].ToString();
result += string.Format("Your GPA : {0} </br> ",_AGPA);
Response.Write(result);
reader.Close();
}
我很确定 SQL 语法是错误的 我收到这个错误
请告知如何解决它以及我在哪里做错了。
谢谢
更新 :
数据类型如下和我使用 SQL Server 数据库
更新 2:
StudentId 通过页面的 URL 传递,如下所示
http://localhost:3401/MobileWebWIthConnection/showagpa.aspx?StudentId=20111
在我读的代码中
string StudentId = Request.Params["StudentId"];