Skip to content

Recuperar registro de la BBDD y mostrar en un ComboBox desplegable

December 22, 2011

Private Sub carregaComboUsuaris()

Try

           
Dim sSQL As String = “SELECT accio, descripcio “ & _

“FROM taula” & _

“ORDER BY accio “

Dim idReader As SqlDataReader = New SqlCommand(cmdText:=sSQL, Connection:=g_cn).ExecuteReader()

ComboBox1.Items.Clear()

With idReader

While .Read()

ComboBox1.Items.Add(UCase((Trim(.GetString(1)))))

‘ComboBox1.Items.Add(UCase((Trim(.GetString(0)) & Space(8)).Substring(0, 8) & ” ” & .GetString(1)))

End While

End With

idReader.Close()

Catch

MsgBox(Err.Number & ” “ & Err.Description, vbOKOnly, “ERROR”)

Exit Sub

End Try

End Sub

From → Datos

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: