Imports Oracle.DataAccess.Client
Public Class selectitem
Dim oradb As String = "Data Source=127.0.0.1;User Id=hr;Password=hr"
Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
Dim conn As New OracleConnection(oradb)
Dim sb As New System.Text.StringBuilder
Dim sbb As New System.Text.StringBuilder
Try
conn.Open()
Dim sql As String = "SELECT * FROM MYTABLE"
Dim cmd As New OracleCommand(sql, conn)
cmd.CommandType = CommandType.Text
sb.Append("INSERT INTO ")
sb.Append(" MYTABLE(MEMBER_ID, INVENTORY_NAME, AMOUNT_BORROW)")
sb.Append(" VALUES(:MEMBER_ID, :INVENTORY_NAME, :AMOUNT_BORROW)")
sql = sb.ToString
cmd.CommandText = sql
With cmd
.Parameters.Clear()
.Parameters.Add(":MEMBER_ID", OracleDbType.Int64).Value = txtIDmember.Text.Trim
.Parameters.Add(":INVENTORY_NAME", OracleDbType.Varchar2).Value = chkitem_1.Text.Trim
.Parameters.Add(":AMOUNT_BORROW", OracleDbType.Int32).Value = txtamout_1.Text.Trim
.Parameters.Add(":INVENTORY_NAME", OracleDbType.Varchar2).Value = chkitem_2.Text.Trim
.Parameters.Add(":AMOUNT_BORROW", OracleDbType.Int32).Value = txtamout_2.Text.Trim
If .ExecuteNonQuery() = 1 Then
MessageBox.Show("เพิ่มข้อมูลเรียบร้อย", "Add new Completed...", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else ' เท่ากับ ศูนย์ คือ ทำงานไม่สำเร็จ
MessageBox.Show("ไม่สามารถเพิ่มข้อมูลได้", "Problem...", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End With
Catch ex As Exception
MessageBox.Show(ex.Message.ToString())
Finally
conn.Dispose()
End Try
End Sub
End Class