hi guys, im trying to use the combobox to update/edit/view the saved data (in contact form) from sql server.
my Load_Combobox (in contact form):
My Public Sub New (in contact form):
My Load_Contact (in Contact form):
kindly assist.
my Load_Combobox (in contact form):
Private Sub Load_Combobox()
'Type
cboType.Items.Add("Director")
cboType.Items.Add("Principal")
cboType.Items.Add("Project Manager")
cboType.Items.Add("Technical Manager")
cboType.SelectedIndex = 0
My Public Sub New (in contact form):
Public Sub New(ByVal nDataFlag1 As Integer)
'Set combobox value
Load_Combobox()
End Sub
My Load_Contact (in Contact form):
In clsDBConnect.vb:Private Sub Load_Contact(ByVal nClientID As Integer)
Dim lcSQL As String
Dim lnComboboxIndex As Integer
lcSQL = " SELECT * FROM client WHERE CLIENTID = " & nClientID
frmMain.objDB.QueryRecord(lcSQL)
While frmMain.objDB.oQuery.Read()
If frmMain.objDB.oQuery.HasRows And Not frmMain.objDB.oQuery.IsDBNull(0) Then
txtName.Text = frmMain.objDB.oQuery.GetString(1)
txtFirm.Text = frmMain.objDB.oQuery.GetString(2)
txtAddress.Text = frmMain.objDB.oQuery.GetString(3)
txtFax.Text = frmMain.objDB.oQuery.GetString(4)
txtPhone.Text = frmMain.objDB.oQuery.GetString(5)
txtEmail.Text = frmMain.objDB.oQuery.GetString(6)
lnComboboxIndex = cboType.FindStringExact(frmMain.objDB.oQuery.GetString(7).Trim())
cboType.SelectedIndex = lnComboboxIndex
End If
End While
End Sub
the problem now is when i saved a record into sql server (EG Technical Manager) and try to view back the saved data, it always show the first item (Director) in combobox. but, my sql server has saved is "Technical Manager" for that saved record.Public Sub GetContactType()
Dim loDataAdpr As OleDbDataReader
Dim loCmdSQL As OleDbCommand
oContactTypeDt = Nothing
isConnectDB()
Try
loCmdSQL = New OleDbCommand()
loCmdSQL.CommandType = CommandType.Text
loCmdSQL.Connection = oConn_ProjMgt
loCmdSQL.CommandText = " SELECT DISTINCT TYPE FROM CLIENT WHERE TYPE IS NOT NULL ORDER BY TYPE "
loDataAdpr = loCmdSQL.ExecuteReader()
oContactTypeDt = New DataTable()
oContactTypeDt.Load(loDataAdpr)
Catch OleDBExceptionErr As OleDbException
cMsgStatus = OleDBExceptionErr.Message
End Try
End Sub
kindly assist.