Paul Hartland
paul.hartland at googlemail.com
Thu Feb 12 02:01:06 CST 2015
To all, I have only really developed in MS Access and Visual Basic 6.0....I am on a learning curve at work where we have Visual Studio Express 2012 installed on my machine. I have the following code to populate a combobox : Dim adtRequestCodes As New SqlDataAdapter() Dim dsRequestCodes As New DataSet() Try Dim cmdPIPRequestCodes As New SqlCommand() cmdPIPRequestCodes.Connection = pADOPIPConn cmdPIPRequestCodes.CommandText = "phPIP_RequestCodes" cmdPIPRequestCodes.CommandType = CommandType.StoredProcedure adtRequestCodes.SelectCommand = cmdPIPRequestCodes adtRequestCodes.Fill(dsRequestCodes) adtRequestCodes.Dispose() cmdPIPRequestCodes.Dispose() Me.cmbRequestCodes.DataSource = dsRequestCodes.Tables(0) Me.cmbRequestCodes.ValueMember = "ReasonID" Me.cmbRequestCodes.DisplayMember = "ReasonCode" Catch ex As Exception MsgBox(ex.Message) End Try This works as it populates the ComboBox. However I have datatable called tblPIPRequests which I use to populate textboxes with data using something like ' Me.txtResolvedBy.DataBindings.Add("Text", tblPIPRequests, "ResolvedByName") '. But can't figure out how to have the combobox show the value of RequestCode from the datatable I.e. in the datatable 'tblPIPRequests' say the 'RequestCode' is 4 I need the combobox to show the 'ReasonCode' associated with RequestCode 4 which would be 'Incorrect Desription' It may even be that I have set this all up wrong for what I need, I have been googling here and there just to get where I am now. Any help GREATLY appreciated. -- Paul Hartland paul.hartland at googlemail.com