asifthakur
asked on
A new record inserted into DB on each refresh.
This is the click functionality in the code behind on the send button that submits the form.
Private Sub ibtnfrmSend_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEv entArgs) Handles ibtnfrmSend.Click
Dim lReturn As Boolean
pi_obj_Message = New Trade_BL.Message
Try
lReturn = pi_obj_Message.PostMessage (Session(S ession_str _UserName) , txthTo.Value, txtSubject.Text, Server.HtmlEncode(fckEdito r.Value))
Catch ex As Exception
Trace.Write(ex.Message)
Exit Sub
End Try
lblMsg.Text = "Message sent successfully"
lblMsg.Visible = True
ClearForm()
End Sub
this is the implementation in the business logic.
Public Function PostMessage(ByVal prm_Sender_ID As String, ByVal prm_To_ID As String, ByVal prm_Subject As String, ByVal prm_Content As String) As Boolean
Dim idbparameter(4) As IDataParameter
Dim idb_Member_Cat_parameter(1 ) As IDataParameter
Dim dt_row As DataRow
Dim objTransaction As IDbTransaction
Dim objConnection As IDbConnection
objConnection = pi_objHelper.GetConnection (GlobalDat a.Connecti onString)
objConnection.Open()
objTransaction = objConnection.BeginTransac tion()
idbparameter(0) = GlobalData.DataHelper.GetP arameter(" @sender_id ", DbType.String, 20, ParameterDirection.Input)
idbparameter(0).Value = prm_Sender_ID
.. other parameters..
Try
pi_objHelper.ExecuteNonQue ry(objTran saction, CommandType.StoredProcedur e, "USP_INSERT_MESSAGE", idbparameter)
Catch ex As Exception
objTransaction.Rollback()
objConnection.Close()
Trace.Write(ex.Message)
Return False
End Try
objTransaction.Commit()
objConnection.Close()
Return True
End Function
when i insert the first record, the form is hidden and the grid on the same page is displayed.. but does not show the new posting. lets assume .. an member sends an email to himself... once you submit the form the record is inserted.. but the grid that pulls data in the page_load of the same page.. does not show it.. if i try to reload the page.. to force datagrid to pull data.. the entire form submission takes place again.. and a new record is inserted into the db. it keeps happening till the time you goto other page and then come back.
Regards,
Private Sub ibtnfrmSend_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEv
Dim lReturn As Boolean
pi_obj_Message = New Trade_BL.Message
Try
lReturn = pi_obj_Message.PostMessage
Catch ex As Exception
Trace.Write(ex.Message)
Exit Sub
End Try
lblMsg.Text = "Message sent successfully"
lblMsg.Visible = True
ClearForm()
End Sub
this is the implementation in the business logic.
Public Function PostMessage(ByVal prm_Sender_ID As String, ByVal prm_To_ID As String, ByVal prm_Subject As String, ByVal prm_Content As String) As Boolean
Dim idbparameter(4) As IDataParameter
Dim idb_Member_Cat_parameter(1
Dim dt_row As DataRow
Dim objTransaction As IDbTransaction
Dim objConnection As IDbConnection
objConnection = pi_objHelper.GetConnection
objConnection.Open()
objTransaction = objConnection.BeginTransac
idbparameter(0) = GlobalData.DataHelper.GetP
idbparameter(0).Value = prm_Sender_ID
.. other parameters..
Try
pi_objHelper.ExecuteNonQue
Catch ex As Exception
objTransaction.Rollback()
objConnection.Close()
Trace.Write(ex.Message)
Return False
End Try
objTransaction.Commit()
objConnection.Close()
Return True
End Function
when i insert the first record, the form is hidden and the grid on the same page is displayed.. but does not show the new posting. lets assume .. an member sends an email to himself... once you submit the form the record is inserted.. but the grid that pulls data in the page_load of the same page.. does not show it.. if i try to reload the page.. to force datagrid to pull data.. the entire form submission takes place again.. and a new record is inserted into the db. it keeps happening till the time you goto other page and then come back.
Regards,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.