Con = New OracleConnection(StrCon)
Try
Con.Open()
If Con.State = ConnectionState.Open Then
Dim StrSql As String = "SELECT br_no , br_name FROM tbl_branch ORDER BY br_no ASC"
Da.MissingSchemaAction = MissingSchemaAction.AddWithKey
Da.SelectCommand = New OracleCommand(StrSql, Con)
Try
Da.Fill(Ds, "branch")
With Combo_Branch
.DataSource = Ds.Tables("branch")
.DisplayMember = "br_name"
.ValueMember = "br_no"
End With
Ds.Clear()
Con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
MessageBox.Show("Oracle Connect Failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Private Sub GetDriver2DDL()
Try
objConn = New SqlConnection(sysconfig)
If (objConn.State = ConnectionState.Open) Then
objConn.Close()
End If
objConn.Open()
Dim sqlDriver As String
Dim dt As New DataTable
sqlDriver = "--- SQL Select --- '"
objCmd = New SqlCommand(sqlDriver, objConn)
dtAdapter = New SqlDataAdapter(objCmd)
dtAdapter.Fill(dt)
If dt.Rows.Count > 0 Then
ddlDriverEditForm.DataSource = dt
ddlDriverEditForm.DataTextField = "br_name"
ddlDriverEditForm.DataValueField = "br_no"
ddlDriverEditForm.DataBind()
ddlDriverEditForm.Items.Insert(0, "-- กรุณาเลือก --")
End If
Catch ex As Exception
Finally
objConn.Close()
End Try
End Sub
Con = New OracleConnection(StrCon)
Try
Con.Open()
If Con.State = ConnectionState.Open Then
Dim StrSql As String = "SELECT br_no , br_name FROM tbl_branch ORDER BY br_no ASC"
Da.MissingSchemaAction = MissingSchemaAction.AddWithKey
Da.SelectCommand = New OracleCommand(StrSql, Con)
Try
Da.Fill(Ds, "branch")
'เพิ่มตรงนี้ ครับ ไม่รู้เขียนถูกหรือเปล่า แต่ก็น่า จะ ประมาณนี้ ครับ
Dim _dt as new Datatable
Dim _dr as Datarow
_dt = Ds.Tables("branch")
_dr = _dt.Newrow()
_dr("br_no") = "0"
_dr("br_name") = "---กรุณาเลือก---"
With Combo_Branch
.DataSource = _dt ' เปลี่ยน เป็น _dt
.DisplayMember = "br_name"
.ValueMember = "br_no"
End With
Ds.Clear()
Con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
MessageBox.Show("Oracle Connect Failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try