
29/06/2011, 16:37
|
| | Fecha de Ingreso: noviembre-2010 Ubicación: madrid
Mensajes: 478
Antigüedad: 14 años, 3 meses Puntos: 5 | |
Respuesta: if para solucionar un error intente esto y casi está, pero cuando las líneas afectadas son 0 no me salta el mensaje
Public Sub copiaintro()
Dim adapta2 As New OleDbDataAdapter
Dim datavacio As New DataSet
Try
'creo los parametros que uso en el SELECT, para filtrar en el datagridview(dgtotales)
Dim comados = conexion.CreateCommand
comados.CommandType = CommandType.Text
Dim comatres = conexion.CreateCommand
comatres.CommandType = CommandType.Text
Dim comacuatro = conexion.CreateCommand
comacuatro.CommandType = CommandType.Text
Dim comacinco = conexion.CreateCommand
comacinco.CommandType = CommandType.Text
comatres.CommandText = "INSERT INTO FechasFiltro SELECT Fecha FROM [Introducción De Ventas] WHERE Fecha BETWEEN @FI AND @FF Order by Fecha"
comatres.Parameters.AddWithValue("@FI", Fecha1.Value.Date.ToString("dd/MM/yyyy"))
comatres.Parameters.AddWithValue("@FF", Fecha2.Value.Date.ToString("dd/MM/yyyy"))
comacuatro.CommandText = "INSERT INTO FechasFiltroFinal SELECT Fecha FROM FechasFiltro WHERE FechasFiltroFinal.Fecha <> FechasFiltro.Fecha group by Fecha"
comacuatro.Parameters.AddWithValue("@FI", Fecha1.Value.Date.ToString("dd/MM/yyyy"))
comacuatro.Parameters.AddWithValue("@FF", Fecha2.Value.Date.ToString("dd/MM/yyyy"))
comacinco.CommandText = "Delete From FechasFiltro"
comacinco.Parameters.AddWithValue("@FI", Fecha1.Value.Date.ToString("dd/MM/yyyy"))
comacinco.Parameters.AddWithValue("@FF", Fecha2.Value.Date.ToString("dd/MM/yyyy"))
comados.CommandText = "INSERT INTO IntroduccionDeVentasAhora SELECT * FROM [Introducción De Ventas] WHERE Fecha BETWEEN @FI AND @FF order by Fecha"
comados.Parameters.AddWithValue("@FI", Fecha1.Value.Date.ToString("dd/MM/yyyy"))
comados.Parameters.AddWithValue("@FF", Fecha2.Value.Date.ToString("dd/MM/yyyy"))
conexion.Open()
Dim lecto3 = comatres.ExecuteNonQuery
'Dim lecto4 = comacuatro.ExecuteNonQuery
Dim rowsAffected As Integer
rowsAffected = comacuatro.ExecuteNonQuery()
If rowsAffected = 0 Then
MessageBox.Show("Datos Duplicados", "Aviso GesDreamtPos Fechas Duplicadas")
Else
Dim Lecto1 = comados.ExecuteNonQuery
Dim lecto5 = comacinco.ExecuteNonQuery
End If
cargacomboMostradores()
cargacomboTerminales()
'cargacombos()
MessageBox.Show("Se han copiado los datos seleccionados entre fechas " + Fecha1.Value.Date.ToString("dd/MM/yyyy") + " y " + Fecha2.Value.Date.ToString("dd/MM/yyyy"), "")
'LbFechaPrimera.Visible = True
cargafechaslabelprimera1()
'LbFechasultima.Visible = True
cargafechaslabelultima1()
'Lhasta.Visible = True
conexion.Close()
'Catch
Catch
End Try
'BPasa.Enabled = False
End Sub |