elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


  Mostrar Mensajes
Páginas: 1 2 3 4 5 6 7 [8] 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
71  Programación / Bases de Datos / consulta SQL en: 25 Mayo 2012, 20:58 pm
Hola a todos, os comento lo que quiero realizar y a continuación os pongo la consulta que he realizado para ello:
     - quiero que en el combo1 tengo el nombre de los clientes y quiero conseguir es el Id_Venta.
      codigo que yo he realizado:
         
Código
  1.          "SELECT Ventas.Id_Ventas FROM Ventas WHERE Ventas.Id_Cliente IN (SELECT Clientes.Id_Cliente FROM Clientes WHERE Clientes.Nombre='" & cbb_Cod_Venta_Instalacion_ins.Text & "')"
  2.  
                  El ultimo combo es el nombre del cliente

Las tablas son las siguientes:
Clientes                       Insatlaciones                    Ventas
Id_Cliente                        Id_Instalacion                   Id_Ventas
Nombre                            Descripcion                       Fecha_Venta
Apellidos                           ......                                 ..........
DNI                                  Id_Venta                          Id_Stock
.......                                 Id_Empleado                    Id_Empleado
                                                                               Id_Cliente
72  Programación / .NET (C#, VB.NET, ASP) / error al insertar en la base de datos en: 25 Mayo 2012, 16:53 pm
Hola a todos, tengo un error al insertar en la base de datos, el cual me dice "Error no especificado" y la verdad es que no consigo encontrar el fallo, os pongo el código para ver si me pueden ayudar
Código
  1. Private Sub btn_Insertar_Ventas_Clientes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Insertar_Ventas_Clientes.Click
  2.        Dim id_marc, id_emp, id_cli As Integer
  3.  
  4.        ' compruebo que ninguno de los datos de venta a cliente esta vacio
  5.        If cbb_Venta_Client_Insertar.Text = "" Or cbb_Nomb_Emp_Vent_Insertar.Text = "" Or
  6.            cbb_Apel_Emp_Vent_Insertar.Text = "" Or cbb_Marca_Artic_Vent_Insertar.Text = "" Or
  7.            cbb_Articulo_Artic_Vent_Insertar.Text = "" Or cbb_Nomb_Client_Vent_Insertar.Text = "" Or
  8.            cbb_Apel_Client_Vent_Insertar.Text = "" Then
  9.            MessageBox.Show("Alguno/s de los datos del articulo esta vacio, rellenelo", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
  10.            Exit Sub
  11.        End If
  12.  
  13.        ' consulta para asignar el Id_Marca eligiendo el nombre del proveedor a la tabla modelos
  14.        Dim dtadapterMarca As OleDbDataAdapter = New OleDbDataAdapter("SELECT Id_Marca FROM Marcas WHERE Marcas.Marca='" & cbb_Marca_Artic_Vent_Insertar.Text & "'", conexion_access)
  15.        Dim dtsMarca As New DataSet
  16.        dtadapterMarca.Fill(dtsMarca, "Marcas")
  17.        For Each Fila As DataRow In dtsMarca.Tables("Marcas").Rows
  18.            id_marc = Fila("Id_Marca")
  19.        Next
  20.  
  21.        ' consulta para asignar el Id_empleado eligiendo el empleado
  22.        'Dim id_emp As Integer
  23.        Dim dtadapterEmpleado As OleDbDataAdapter = New OleDbDataAdapter("SELECT Empleados.Id_Empleado FROM Empleados WHERE Empleados.Nombre='" & cbb_Nomb_Emp_Compra.Text & "' AND Empleados.Apellidos='" & cbb_Apel_Emp_Vent_Insertar.Text & "'", conexion_access)
  24.        Dim dtsEmpleado As New DataSet
  25.  
  26.        dtadapterEmpleado.Fill(dtsEmpleado, "Empleados")
  27.        For Each Fila As DataRow In dtsEmpleado.Tables("Empleados").Rows
  28.            id_emp = Fila("Id_Empleado")
  29.        Next
  30.  
  31.        ' consulta para asignar el Id_cliente eligiendo el nombre del cliente a la tabla ventas
  32.        Dim dtadapterCliente As OleDbDataAdapter = New OleDbDataAdapter("SELECT Id_Cliente FROM Clientes WHERE Clientes.Nombre='" & cbb_Nomb_Client_Vent_Insertar.Text & "' AND Clientes.Apellidos='" & cbb_Apel_Client_Vent_Insertar.Text & "'", conexion_access)
  33.        Dim dtsCliente As New DataSet
  34.        dtadapterCliente.Fill(dtsCliente, "Clientes")
  35.        For Each Fila As DataRow In dtsCliente.Tables("Clientes").Rows
  36.            id_cli = Fila("Id_Cliente")
  37.        Next
  38.  
  39.        ' inserto los datos en la tabla ventas
  40.        Dim CadenaSql As String = "INSERT INTO Ventas (Fecha_Venta, Pagado, Id_Stock, Id_Empleado, Id_Cliente) VALUES ('" & CDate(cbb_Venta_Client_Insertar.Text) & "'," & chk_Pagado_Venta_Insertar.Checked & "," & "(SELECT TOP 1 Stock.Id_Stock FROM Stock WHERE Stock.Id_Articulo IN (SELECT Articulos.Id_Articulos FROM Articulos WHERE Articulos.Descripcion='" & cbb_Articulo_Artic_Vent_Insertar.Text & "' AND Stock.Vendido=False))," & "(SELECT Empleados.Id_Empleado FROM Empleados WHERE Empleados.Nombre='" & cbb_Nomb_Emp_Vent_Insertar.Text & "' AND Empleados.Apellidos='" & cbb_Apel_Emp_Vent_Insertar.Text & "')," & "(SELECT Clientes.Id_Cliente FROM Clientes WHERE Clientes.Nombre='" & cbb_Nomb_Client_Vent_Insertar.Text & "' AND Clientes.Apellidos='" & cbb_Apel_Client_Vent_Insertar.Text & "'))"
  41.  
  42.        MsgBox(IdStock)
  43.        MsgBox(CadenaSql)
  44.        Dim Comando As New OleDb.OleDbCommand(CadenaSql, conexion_access)
  45.        Comando.Connection.Open()
  46.        Comando.ExecuteNonQuery()
  47.        If Mensaje = "" Then
  48.            MessageBox.Show("La venta se ha insertado correctamente.", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information)
  49.        Else
  50.            MessageBox.Show("La venta se ha insertado correctamente. Debe dispensar al cliente el artículo con número de serie: " & Mensaje, "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information)
  51.        End If
  52.  
  53.         ' ME GUSTARÍA SABER SI TENGO QUE REDIMENSIONAR LA MATRIZ
  54.        ' redimensionamos el tamaño de la matriz
  55.        'ReDim Preserve S_Ventas(S_Ventas.Length)
  56.  
  57.        ' para refrescar la tabla me tengo que crear 2 variables
  58.        Dim ta_venta As New ArcoclimaDataSetTableAdapters.VentasTableAdapter
  59.        Dim tabla_venta As New ArcoclimaDataSet.VentasDataTable
  60.  
  61.        ' refrescamos los valores de la tabla
  62.        tabla_venta = ta_venta.GetData
  63.        ArticulosDataGridView.DataSource = tabla_venta
  64.  
  65.        Me.Validate()
  66.        Me.VentasBindingSource.EndEdit()
  67.        Me.TableAdapterManager.UpdateAll(Me.ArcoclimaDataSet)
  68.  
  69.        Comando.Connection.Close()
  70.  
  71.        ' Limpio el contenido de los TextBox que he insertado en la tabla de empleados
  72.        Limpiar_TextBox(cbb_Marca_Artic_Vent_Insertar.Text, cbb_Articulo_Artic_Vent_Insertar.Text,
  73.                        cbb_Nomb_Emp_Vent_Insertar.Text, cbb_Apel_Emp_Vent_Insertar.Text,
  74.                        cbb_Nomb_Client_Vent_Insertar.Text, cbb_Apel_Client_Vent_Insertar.Text)
  75.        Exit Sub
  76.    End Sub
  77.  

El Id me lo devuelve correcto, pero no se si el error esta en la consulta o en el código, espero que me puedan ayudar,

Saludos
73  Programación / .NET (C#, VB.NET, ASP) / Re: error ExecuteNomQuery en: 24 Mayo 2012, 21:12 pm
ok ya sale correcto!!!

Saludos y gracias
74  Programación / .NET (C#, VB.NET, ASP) / Re: error ExecuteNomQuery en: 24 Mayo 2012, 21:10 pm
que le tendria que hacer un Cdate(cbb_Fecha_Compra.Text)???
75  Programación / .NET (C#, VB.NET, ASP) / Re: error ExecuteNomQuery en: 24 Mayo 2012, 19:47 pm
el campo feche es de tipo date
76  Programación / .NET (C#, VB.NET, ASP) / error ExecuteNomQuery en: 24 Mayo 2012, 19:30 pm
Hola a todos, tengo un error en este código que no consigo solucionar, el error esta en Comando.ExecuteNonQuery() me dice:
      No coinciden los tipos de datos en la expresión de criterios.

Código
  1. Private Sub btn_Comprar_Articulo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Comprar_Articulo.Click
  2.        ' compruebo que ninguno de los datos de reparacion esta vacio
  3.        ' compra por articulo
  4.        If grb_Datos_Articulo.Enabled = False Then
  5.            If cbb_B_Arc_Marca_Compras.Text = "" Or cbb_B_Arc_Articulo_Compras.Text = "" Or
  6.                cbb_Nomb_Emp_Compra.Text = "" Or cbb_Apel_Emp_Compra.Text = "" Or
  7.                txt_Numero_de_Artículos_Compra.Text = "" Or txt_Num_Serie_Compra.Text = "" Then
  8.                MessageBox.Show("Alguno/s de los campos esta vacio, rellenelo/s", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
  9.                Exit Sub
  10.            End If
  11.        Else
  12.            If grb_Buscar_Art_por_Marca.Enabled = False Then
  13.                If cbb_Nombre_Empres_Compras.Text = "" Or cbb_Modelo_Compra.Text = "" Or cbb_Articulo_Compra.Text = "" Or
  14.                cbb_Nomb_Emp_Compra.Text = "" Or cbb_Apel_Emp_Compra.Text = "" Or
  15.                txt_Numero_de_Artículos_Compra.Text = "" Or txt_Num_Serie_Compra.Text = "" Then
  16.                    MessageBox.Show("Alguno/s de los campos esta vacio, rellenelo/s", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
  17.                    Exit Sub
  18.                End If
  19.            End If
  20.        End If
  21.  
  22.        ' consulta para asignar el Id_Articulo eligiendo la marca
  23.        Dim id_artic As Integer
  24.        Dim dtadapterArticulo1 As New OleDb.OleDbDataAdapter("SELECT Id_Articulos FROM Articulos WHERE Articulos.Descripcion='" & cbb_B_Arc_Articulo_Compras.Text & "' ORDER BY Articulos.Id_Articulos", conexion_access)
  25.        Dim dtsArticulo As New DataSet
  26.  
  27.        dtadapterArticulo1.Fill(dtsArticulo, "Articulos")
  28.        For Each Fila As DataRow In dtsArticulo.Tables("Articulos").Rows
  29.            id_artic = Fila("Id_Articulos")
  30.        Next
  31.  
  32.        ' consulta para asignar el Id_empleado eligiendo el empleado
  33.        Dim id_emp As Integer
  34.        Dim dtadapterEmpleado As OleDbDataAdapter = New OleDbDataAdapter("SELECT Empleados.Id_Empleado FROM Empleados WHERE Empleados.Nombre='" & cbb_Nomb_Emp_Compra.Text & "' AND Empleados.Apellidos='" & cbb_Apel_Emp_Compra.Text & "'", conexion_access)
  35.        Dim dtsEmpleado As New DataSet
  36.  
  37.        dtadapterEmpleado.Fill(dtsEmpleado, "Empleados")
  38.        For Each Fila As DataRow In dtsEmpleado.Tables("Empleados").Rows
  39.            id_emp = Fila("Id_Empleado")
  40.        Next
  41.  
  42.        MsgBox("Ejecutando consulta")
  43.        Dim CadenaSql As String = "INSERT INTO Stock (Num_Serie, Vendido, Fecha, Id_Articulo, Id_Empleado) VALUES ('" & txt_Num_Serie_Compra.Text & "', False, '" & cbb_Fecha_Compra.Text & "'," & id_artic & "," & id_emp & ")"
  44.        Dim Comando As New OleDbCommand(CadenaSql, conexion_access)
  45.        Comando.Connection.Open()
  46.        Comando.ExecuteNonQuery()
  47.  
  48.        ' recimensionamos el tamaño de la matriz
  49.        ReDim Preserve S_Stock(S_Stock.Length)
  50.  
  51.        ' para refrescar la tabla me tengo que crear 2 variables
  52.        Dim ta_stock As New ArcoclimaDataSetTableAdapters.StockTableAdapter
  53.        Dim tabla_stock As New ArcoclimaDataSet.StockDataTable
  54.  
  55.        ' refrescamos los valores de la tabla
  56.        tabla_stock = ta_stock.GetData
  57.        StockDataGridView.DataSource = tabla_stock
  58.  
  59.        Me.Validate()
  60.        Me.StockBindingSource.EndEdit()
  61.        Me.TableAdapterManager.UpdateAll(Me.ArcoclimaDataSet)
  62.  
  63.        ' limpio el contenido de los TextBox que he insertado en la tabla Stock
  64.        Limpiar_TextBox(cbb_Nombre_Empres_Compras.Text, cbb_Modelo_Compra.Text, cbb_Articulo_Compra.Text,
  65.                        cbb_B_Arc_Marca_Compras.Text, cbb_B_Arc_Articulo_Compras.Text, cbb_Nomb_Emp_Compra.Text,
  66.                        cbb_Apel_Emp_Compra.Text, txt_Numero_de_Artículos_Compra.Text, txt_Num_Serie_Compra.Text)
  67.  
  68.        Comando.Connection.Close()
  69.  
  70.    End Sub
  71.  

Espero que me puedan ayudar

Saludos
77  Programación / .NET (C#, VB.NET, ASP) / Re: consulta en .NET en: 7 Mayo 2012, 13:51 pm
Solucionado!!!!!
78  Programación / .NET (C#, VB.NET, ASP) / Re: consulta en .NET en: 5 Mayo 2012, 17:17 pm
yo lo que quiero hacer el elegir un proveedor y que me ponga el id_proveedor que tiene asignado en la tabla, es algo sencillo en sql, pero al no haberlo implementado nunca en .NET no me termina de salir bien.
79  Programación / .NET (C#, VB.NET, ASP) / Re: consulta en .NET en: 5 Mayo 2012, 13:23 pm
No sale bien, al cambiar el proveedor me deja el mismo Id_proveedor, he cambiado la consulta, porque creo que no estaba bien, esta es la consulta modificada:

Código
  1. Dim consulta As New OleDbCommand("SELECT Id_Proveedor FROM  Proveedores WHERE Marca = " & cbb_Marca_Prov.Text, conexion_access)
  2.  

la he cambiado porque lo que quiero mostrar el el id_proveedor donde la marca sea igual a la elegida en el ComboBox.

Saludos
80  Programación / .NET (C#, VB.NET, ASP) / consulta en .NET en: 4 Mayo 2012, 22:59 pm
Hola a todos, estoy realizando una consulta en .NET de una base de datos de Access. El codigo que he generado es el siguiente:

Código
  1. Imports System.Data.OleDb
  2.  
  3. ' me he creado un objeto para establecer la conexión
  4. Public conexion_access As New OleDb.OleDbConnection
  5.  
  6. ' cadena de conexión
  7. conexion_access = New OleDbConnection(" Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\carlos\Escritorio\Proyecto Ingegrado Carlos Barea Grado Superior\base de datos\Arcoclima.mdb")
  8.  

Ahora este es el código que me he creado con la consulta
Código
  1. Private Sub cbb_Marca_Prov_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbb_Marca_Prov.SelectedIndexChanged
  2.        Dim i, j As Integer
  3.        Dim marca_prov, id_prov_comp As String
  4.  
  5.        For i = 0 To ProveedoresTableAdapter.GetData.Rows.Count - 1
  6.            marca_prov = ProveedoresTableAdapter.GetData.Rows(i).Item(3)
  7.  
  8.            For j = 0 To CompraTableAdapter.GetData.Rows.Count - 1
  9.                id_prov_comp = CompraTableAdapter.GetData.Rows(j).Item(0)
  10.  
  11.                txt_Id_Proveedor_compra.Text = id_prov_comp
  12.                Exit For
  13.            Next
  14.  
  15.            Dim consulta As New OleDbCommand("SELECT Compra.Id_Proveedor FROM  Proveedores", conexion_access)
  16.  
  17.            conexion_access.Open()
  18.           [color=red] txt_Id_Proveedor_compra.Text = CType(consulta.ExecuteNonQuery(), String)[/color]
  19.        Next
  20.    End Sub
  21.  

El error me lo da en la linea de color rojo y me dice lo siguiente:
       "No se han especificado valores para algunos de los parámetros requeridos."

Espero que me puedan ayudar a solucionar el problema

Saludos
Páginas: 1 2 3 4 5 6 7 [8] 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines