tendre malo el insert?
aqui les va los datos
Esta es la base de datos:
[IMG][URL=http://imageshack.us/photo/my-images/193/11714182.jpg/][IMG]http://img193.imageshack.us/img193/9306/11714182.jpg[/IMG][/URL] [/IMG]
Este es el error
[IMG][URL=http://imageshack.us/photo/my-images/717/errorrrrrrrrrrrrrrrrrrr.jpg/][IMG=http://img717.imageshack.us/img717/5858/errorrrrrrrrrrrrrrrrrrr.jpg][/IMG][/URL] [/IMG]
Este es el código:
Código vb:
Ver original
Private Sub AccionesLibros_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load myConn = New SqlConnection("Initial Catalog=libroteka;Data Source=localhost;Integrated Security=SSPI;") myConn.Open() myCmd = myConn.CreateCommand myCmd.CommandText = "SELECT * FROM editoriales" adaptor.SelectCommand = myCmd adaptor.Fill(dataset) ' aqui le ingreso los nombre de editoriales al combobox rut_edi.DisplayMember = "nombre_edi" rut_edi.ValueMember = "rut_edi" rut_edi.DataSource = dataset.Tables(0) myConn.Close() myConn = New SqlConnection("Initial Catalog=libroteka;Data Source=localhost;Integrated Security=SSPI;") myConn.Open() myCmd = myConn.CreateCommand myCmd.CommandText = "SELECT * FROM proveedores" adaptorr.SelectCommand = myCmd adaptorr.Fill(datasett) ' aqui le ingreso los nombre de proveedores al combobox rut_pro2.DisplayMember = "nombre_pro" rut_pro2.ValueMember = "rut_pro" rut_pro2.DataSource = datasett.Tables(0) myConn.Close() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim NN If cod_libro.Text = "" Or nombre_libro.Text = "" Or anio_libro.Text = "" Or autor.Text = "" Or resumen.Text = "" Or categoria.Text = "" Or precio.Text = "" Or rut_pro2.Text = "" Or rut_edi.Text = "" Then NN = MsgBox("Debe ingresar todos los datos.", vbExclamation, "Ingrese los datos.") Else dataset.Reset() myCmd.CommandText = "SELECT * FROM libros WHERE cod_libro ='" & cod_libro.Text & "' " myConn.Open() adaptor.SelectCommand = myCmd adaptor.Fill(dataset, "0") Dim count = dataset.Tables(0).Rows.Count If count > 0 Then MsgBox("libro ya existe", MsgBoxStyle.Critical) myConn.Close() End If dataset.Reset() If count = 0 Then myConn.Close() myConn = New SqlConnection("Initial Catalog=libroteka;Data Source=localhost;Integrated Security=SSPI;") myCmd = myConn.CreateCommand myCmd.CommandText = " INSERT INTO libros VALUES('" & cod_libro.Text & "','" & nombre_libro.Text & "','" & anio_libro.Text & "','" & autor.Text & "','" & resumen.Text & "','" & categoria.Text & "','" & precio.Text & "','" & rut_pro2.Text & "','" & rut_edi.Text & "','" & 1 & "') SELECT proveedores.rut_pro, editoriales.rut_edi FROM proveedores, editoriales WHERE proveedores.rut_pro = '" & rut_pro2.SelectedValue & "' AND editoriales.rut_edi = '" & rut_edi.SelectedValue & "' " myConn.Open() myReader = myCmd.ExecuteReader() MsgBox("Se ha ingresado un nuevo Libro", MsgBoxStyle.Information, "Felicidades!!") myReader.Close() myConn.Close() End If End If End Sub