Quem puder me ajudar, segue o código abaixo:
'carrega pesquisas Public Sub carrega_pesquisas() Dim strCarrega As String Dim daCarrega As OleDbDataAdapter Dim dsCarrega As New DataSet() Try 'abre conexao objConnP.Open() 'monta select strCarrega = "SELECT cod_pesquisa, " & _ "desc_pesquisa " & _ "FROM pesquisas " & _ "ORDER BY desc_pesquisa" daCarrega = New OleDbDataAdapter(strCarrega, objConnP) 'executa o comando daCarrega.Fill(dsCarrega, "Pesquisas") 'monta o combo box With cbPesquisas .DataSource = dsCarrega.Tables("Pesquisas") .DisplayMember = "desc_pesquisa" .ValueMember = "cod_pesquisa" End With cbPesquisas.SelectedIndex = 0 txtPergunta.Text = CType(cbPesquisas.SelectedValue, String) Catch erro As Exception MsgBox("Erro (008): " & erro.Message, MsgBoxStyle.Critical) Finally 'fecha conexao objConnP.Close() End Try End Sub Private Sub cbPesquisas_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbPesquisas.SelectedIndexChanged 'ativa o campo da pergunta txtPergunta.Enabled = True txtPergunta.Text = CType(cbPesquisas.SelectedValue, String) End Sub
Ele tá dando o seguinte erro:
Cast from type 'DataRowView' to type 'String' is not valid
Quem puder ajudar, obrigado.
Edição feita por: cacfs, 11/03/2005, 16:13.