您好我有三個表如下所示SQL語法來獲得AGPA
我想要得到的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 ";
a次我會這樣打印出來的結果
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();
}
Im相當肯定的SQL語法錯誤 即時得到這個錯誤
請告知如何解決這個問題,並在那裏我做了一個錯誤。
謝謝
更新:
的數據類型是作爲follwoing &進出口使用SQL Server數據庫
更新2:
的StudentId是通過頁面的URL通過如下所示
http://localhost:3401/MobileWebWIthConnection/showagpa.aspx?StudentId=20111
,並在代碼中,我讀它
string StudentId = Request.Params["StudentId"];
我不有c.StudentId,StudentId是使用URL傳遞的,所以我使用了(R.StudentId = StudentId),但它仍然不工作,它顯示錯誤(操作數數據類型nchar對乘法運算符無效)。 – arin
添加數據類型db列,我會看看我應該投什麼專欄,並且請告訴我你使用的數據庫是什麼 – igofed
並且我不想要courseID或StudentID我只需要得到AGPA爲「3.33」 – arin