Hi everyOne..
Are this is a bug ? or my mistake in coding..?
I have 2 function at my component. If i use that 2 function together at my
aspx or aspx file it will result an error. But if i used that function
separate it run well, How it can be happen ??
Here the code :
This code at aspx file :
<script runat="server" language="vb">
dim Article_id as string =""
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Article_id = CStr(Request.Params("Article_id"))
end sub
Sub PushButton(ByVal sender As Object, ByVal e As EventArgs)
dim Pool as new Utility()
dim R_Scor, Count as integer
Dim NewScor as integer = Ctype(RBL1.SelectedItem.Value,integer)
'This is the first function
dim ObjReader as oleDBDataReader = Pool.SelectScor(Article_id)
If not (ObjReader.Read()=Nothing) Then
R_Scor = ObjReader("R_scor")
count = ObjReader("Count")
end if
R_scor = R_Scor + NewScor
Count = Count + 1
Dim rating as integer = R_Scor / Count
response.write("Rating :" & rating)
'This is the second function --> put the function together --> result an
error
Dim Flag as boolean = Pool.InsertNewScor(R_Scor,Count,Article_id)
response.write(Flag)
end sub
</script>
This is code at component :
Imports System
Imports System.Data
Imports System.Data.OleDb
Namespace DotNetArea
Public Class Utility
Public ConnectionString As String
Dim myConnection As New
OleDbConnection(ConfigurationSettings.AppSettings("connectionString"))
'***************************************************
' ARTICLE POOLING
'***************************************************
Public Function InsertNewScor(ByVal R_scor As Integer, ByVal Count
As Integer, ByVal Article_id As String) As Boolean
Dim myCommand As New OleDbCommand("UpdateScor", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
Dim parameterR_scor As New OleDbParameter("@R_scor",
OleDbType.Integer)
parameterR_scor.Value = R_scor
myCommand.Parameters.Add(parameterR_scor)
Dim parameterCount As New OleDbParameter("@Count",
OleDbType.Integer)
parameterCount.Value = Count
myCommand.Parameters.Add(parameterCount)
Dim parameterArticle_id As New OleDbParameter("@Article_id",
OleDbType.VarChar, 10)
parameterArticle_id.Value = Article_id
myCommand.Parameters.Add(parameterArticle_id)
' Open database connection dan menjalankan perintah
Try
myConnection.Open()
myCommand.ExecuteNonQuery()
Catch
' gagal Update User
Return False
Finally
myConnection.Close()
End Try
Return True
End Function
Public Function SelectScor(ByVal Article_id As String) As
OleDbDataReader
Dim myCommand As New OleDbCommand("SelectScor", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
Dim parameterArticle_id As New OleDbParameter("@Article_id",
OleDbType.VarChar, 10)
parameterArticle_id.Value = Article_id
myCommand.Parameters.Add(parameterArticle_id)
myConnection.Open()
Return myCommand.ExecuteReader
myConnection.Close()
End Function
End Class
End Namespace
Thank you
Handoyo
----------------------------------------------------------------------------
Ikuti polling TELKOM Memo 166 di www.plasa.com dan menangkan hadiah masing-masing Rp 250.000 tunai
----------------------------------------------------------------------------