Jump to content
cmtavares

LISTBOX SQL UPDATE

Recommended Posts

cmtavares

Boas pessoal,

capturaraf.jpg

Pessoal sabem me dizer como posso realizar o UPDATE da informação da listbox mais a esquerda?

fica ai a base de dados para ser mais facil!

imageeetl.jpg

Private Sub btnGuardar_Click(sender As Object, e As EventArgs) Handles btnGuardar.Click
    Dim connectionString As String = "Password=irpasimpo;Persist Security Info=True;User ID=SA;Initial Catalog=OEI;Data Source=CARLOS-M\SQL"
    Dim connection As New SqlConnection(connectionString)
    connection.Open()
    Dim command As String = "UPDATE ID_GRUPO FROM Clientes WHERE Nome = (SELECT ID_GRUPO FROM Grupos WHERE Nome ='" & ComboBox1.SelectedItem & "') "
    ' Dim command As New SqlCommand("UPDATE Clientes Set ID_GRUPO=@ID_GRUPO where ID_GRUPO= '" & ComboBox1.SelectedItem & "'", connection)

    'command.Parameters.AddWithValue("@ID_GRUPO", ListBox1.Items)
    'command.ExecuteNonQuery()
    'connection.Close()
    Dim ExecuteComand As New SqlCommand(command, connection)

    'Dim Cmd As New SqlCommand(command, connection)
    'Cmd.Parameters.Add(New SqlParameter("@ID_GRUPO", ListBox1.Items))

    Dim Reader As SqlDataReader = ExecuteComand.ExecuteReader()
    If Reader.HasRows Then
	    While Reader.Read()
		    ListBox1.Items.Add(Reader.Item("Nome"))
	    End While
    End If

Edited by cmtavares

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.