nose como ingresar una nueva fila en el listview
Este es el codigo
Código vb:
Ver original
Imports System.Data.SqlClient Public Class VentaLibros Private myConn As New SqlConnection Private myCmd As New SqlCommand Private results As String Dim adaptor As New SqlClient.SqlDataAdapter Dim dataset As New DataSet Private Sub VentaLibros_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub TbProducto_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TbProducto.KeyPress 'Valido que se ingrese solo numeros If Char.IsNumber(e.KeyChar) Then e.Handled = False 'Valido que se presione Backspace,Enter ElseIf Char.IsControl(e.KeyChar) Then e.Handled = False 'Las demas teclas quedan bloqueadas Else e.Handled = True End If 'Si mando un ENTER entonces que busque If e.KeyChar = Convert.ToChar(Keys.Enter) Then myConn = New SqlConnection("Initial Catalog=libroteka;Data Source=localhost;Integrated Security=SSPI;") 'Crear un objeto Command. myCmd = myConn.CreateCommand myCmd.CommandText = "SELECT * FROM libros WHERE cod_libro ='" & TbProducto.Text & "' " myConn.Open() adaptor.SelectCommand = myCmd adaptor.Fill(dataset, "0") Dim count = dataset.Tables(0).Rows.Count If count > 0 Then With Ltver.Items.Add(TbProducto.Text, "cod_libro") .SubItems.Add(dataset.Tables(0).Rows(0).Item("nombre_libro")) .SubItems.Add(dataset.Tables(0).Rows(0).Item("precio")) End With End If myConn.Close() TbProducto.Clear() dataset.Reset() End If End Sub End Class