Dim getPelajarKelas As Object = Session("Kelas")
cmd.CommandText = "Select COUNT(IdPelajar) From MaklumatPelajar Where Kelas=@Kelas"
cmd.Parameters.AddWithValue("kelas", getPelajarKelas)
double result = Convert.ToDouble(cmd.ExecuteScalar())-35
'Use result.ToString()
afastars
Member
52 Points
221 Posts
calculated field on sql query
Dec 27, 2012 07:58 AM|LINK
i want to make a calculated field on sql query, i need help to do that thing
i want subtract the value with 35, how it can be done expertise..?
this is my code to count value from database,
Dim getPelajarKelas As Object = Session("Kelas")
cmd.CommandText = "Select COUNT(IdPelajar) From MaklumatPelajar Where Kelas=@Kelas"
cmd.Parameters.AddWithValue("kelas", getPelajarKelas)
lbljumpel.Text = "Jumlah Pelajar: " + cmd.ExecuteScalar().ToString
anuj_koundal
Contributor
2088 Points
496 Posts
Re: calculated field on sql query
Dec 27, 2012 08:20 AM|LINK
Your question is not very much clear Lets try:
Regards
Anuj Koundal
sameer_khanj...
Contributor
7066 Points
1381 Posts
Re: calculated field on sql query
Dec 27, 2012 08:21 AM|LINK
Dim getPelajarKelas As Object = Session("Kelas") cmd.CommandText = "Select (COUNT(IdPelajar) -35) as countID From MaklumatPelajar Where Kelas=@Kelas" cmd.Parameters.AddWithValue("kelas", getPelajarKelas) lbljumpel.Text = "Jumlah Pelajar: " + cmd.ExecuteScalar().ToStringsameer.khanjit@gmail.com
View Blog
Click "Mark as Answer" on the post that helped you.
oned_gk
All-Star
31834 Points
6517 Posts
Re: calculated field on sql query
Dec 27, 2012 08:24 AM|LINK
Dim getPelajarKelas As String = Session("Kelas") cmd.CommandText = "Select COUNT(IdPelajar) From MaklumatPelajar Where Kelas=@Kelas" cmd.Parameters.AddWithValue("kelas", getPelajarKelas) lbljumpel.Text = "Jumlah Pelajar: " + cmd.ExecuteScalar().ToStringDecker Dong ...
All-Star
118619 Points
18779 Posts
Re: calculated field on sql query
Dec 28, 2012 12:19 AM|LINK
Hi afastears:)
Just calculate the result from db and do minus:
Dim getPelajarKelas As Object = Session("Kelas") cmd.CommandText = "Select COUNT(IdPelajar) From MaklumatPelajar Where Kelas=@Kelas" cmd.Parameters.AddWithValue("kelas", getPelajarKelas) double result = Convert.ToDouble(cmd.ExecuteScalar())-35 'Use result.ToString()afastars
Member
52 Points
221 Posts
Re: calculated field on sql query
Dec 28, 2012 07:49 AM|LINK
hi all expertise
thanks for reply...all of you give the answer...thanks a lot's i'm new in programming need to leaen a lot's..