PROBLEMAS CON SENTENCIA SQL
TENGO LA SIG. SENTENCIA EN LA CUAL QUIERO AGREGAR TODOS LOS DATOS DE UN GRID A UNA BASE DE DATOS:
For i = 1 To Griddatos.Rows - 1
bus = "insert into temp_PROD (CLAVE,DESCRIPCION,TIPO,CAPACIDAD,PRECIOP, PRECIOM, PRECIOR) values ('" & Griddatos.TextMatrix(i, 0) & "', '" & Griddatos.TextMatrix(i, 1) & "','" & Griddatos.TextMatrix(i, 2) & "', '" & Griddatos.TextMatrix(i, 3) & "','" & Griddatos.TextMatrix(i, 4) & "','" & Griddatos.TextMatrix(i, 5) & "','" & Griddatos.TextMatrix(i, 6) & "')"
Fraiche.Execute (bus)
Next i
LO QUE PASA ES QUE HAY CELDAS EN EL GRID DONDE NO HAY NINGUN DATO, ENTONCES LOS REGISTROS DONDE DEBE APARECER EL CAMPO VACIO NO LOS INSERTA.
AYUDA POR FAVOR
URGEEER!!!!
For i = 1 To Griddatos.Rows - 1
bus = "insert into temp_PROD (CLAVE,DESCRIPCION,TIPO,CAPACIDAD,PRECIOP, PRECIOM, PRECIOR) values ('" & Griddatos.TextMatrix(i, 0) & "', '" & Griddatos.TextMatrix(i, 1) & "','" & Griddatos.TextMatrix(i, 2) & "', '" & Griddatos.TextMatrix(i, 3) & "','" & Griddatos.TextMatrix(i, 4) & "','" & Griddatos.TextMatrix(i, 5) & "','" & Griddatos.TextMatrix(i, 6) & "')"
Fraiche.Execute (bus)
Next i
LO QUE PASA ES QUE HAY CELDAS EN EL GRID DONDE NO HAY NINGUN DATO, ENTONCES LOS REGISTROS DONDE DEBE APARECER EL CAMPO VACIO NO LOS INSERTA.
AYUDA POR FAVOR
URGEEER!!!!
Para empezar, intenta armar una cadena sql en la que cada dato, se concatene en una lÃnea diferente, de ese modo, puedes preguntar en un IF, si la celda está vacÃa o no.
Bus = "insert into temp_PROD (CLAVE,DESCRIPCION,TIPO,CAPACIDAD,PRECIOP, PRECIOM, PRECIOR) values ('"
Bus = Bus & "'" & Griddatos.TextMatrix(i, 0) & "'"
If Griddatos.TextMatrix(i, 1) <> "" then
Bus = Bus & "'" & Griddatos.TextMatrix(i,1) & "'"
else
Bus = Bus & ",Null"
end if
y asà la vas completando, dato por dato verificando el contenido de la celda.
Saludos
Bus = "insert into temp_PROD (CLAVE,DESCRIPCION,TIPO,CAPACIDAD,PRECIOP, PRECIOM, PRECIOR) values ('"
Bus = Bus & "'" & Griddatos.TextMatrix(i, 0) & "'"
If Griddatos.TextMatrix(i, 1) <> "" then
Bus = Bus & "'" & Griddatos.TextMatrix(i,1) & "'"
else
Bus = Bus & ",Null"
end if
y asà la vas completando, dato por dato verificando el contenido de la celda.
Saludos
