Dim slqinsert As String slqinsert = "insert into BBS_COMMU(title,info,accessory,emp_no,emp_name,dpt_no,cre_time,action_id) values(:headline,:content,:attach,:empid,:empname,:dptid,:cretime,:actionno)" Dim parameter(8) As OracleParameter
parameter(0) = New OracleParameter(":headline", OracleType.NVarChar, 30)
parameter(1) = New OracleParameter(":content", OracleType.Clob)
parameter(2) = New OracleParameter(":attach", OracleType.VarChar, 300)
parameter(3) = New OracleParameter(":empid", OracleType.VarChar, 20)
parameter(4) = New OracleParameter(":empname", OracleType.VarChar, 20)
parameter(5) = New OracleParameter(":dptid", OracleType.VarChar, 20)
parameter(6) = New OracleParameter(":cretime", OracleType.VarChar, 40)
parameter(7) = New OracleParameter(":actionno", OracleType.VarChar, 100)
parameter(0).Value = title_txt.Text
parameter(1).Value = info_txt.Text
parameter(2).Value = accessory_txt.Text
parameter(3).Value = user_no
parameter(4).Value = user_no
parameter(5).Value = user_dpt
parameter(6).Value = time
parameter(7).Value = actionid
Dim db_conn As New OracleConnection(connectionString)
db_conn.Open()
Dim cmd As New OracleCommand
Dim trans As OracleTransaction = db_conn.BeginTransaction()
cmd.Transaction = trans
cmd.Connection = db_conn
cmd.CommandText = slqinsert
cmd.Parameters.Add(parameter(0))
cmd.Parameters.Add(parameter(1))
cmd.Parameters.Add(parameter(2))
cmd.Parameters.Add(parameter(3))
cmd.Parameters.Add(parameter(4))
cmd.Parameters.Add(parameter(5))
cmd.Parameters.Add(parameter(6))
cmd.Parameters.Add(parameter(7))
Try
cmd.ExecuteNonQuery()
trans.Commit()
Catch ex As Exception
Try
trans.Rollback()
Throw New ApplicationException(ex.Message)
Catch exe As Exception
If Not trans.Connection Is Nothing Then
Console.WriteLine("An exception of type " & ex.GetType().ToString() & _
" was encountered while attempting to roll back the transaction.")
End If
End Try
Finally
db_conn.Close()
Response.Write("<script>alert('" & " sucees insert into database " & "') </script>")
clearinfo()
Response.Redirect("innerbbs.aspx")
End Try