Ver Mensaje Individual
  #3 (permalink)  
Antiguo 08/04/2013, 10:11
Avatar de yamiblancoc
yamiblancoc
 
Fecha de Ingreso: agosto-2011
Mensajes: 103
Antigüedad: 12 años, 8 meses
Puntos: 4
Respuesta: Problema en Insert

Cita:
Iniciado por JonathanB Ver Mensaje
Saludos, has intentado solo realizar el insert (en una tabla temporal) del contenido de la columna que te ha dado problemas?
Otra cosa que te puede estar afectando, trata de usar parámetros en lugar de ingresarlos directamente.
http://stackoverflow.com/a/542542
Cuando lo realizo con parametros

Código vb:
Ver original
  1. For Each f As DataRow In ds.Tables(0).Rows
  2.                             If filas < ds.Tables(0).Rows.Count - 1 Then
  3.                                 Comm.CommandText = "INSERT INTO [NSO].[dbo].[Audited_Facts_regular]([Fecha_Carga],[CountryID],[ContryName],[StoreID],[NSO_StoreID],[StoreName] " & _
  4.                                 " ,[StoreAddres] ,[StoreStatud],[StoreComments],[StoreStarDateTime],[StoreEndDateTime],[StoreClosing]" & _
  5.                                 " ,[PlannetAudit],[AuditInstructionID],[SyneryMode],[IMDB_ProductID],[NSO_ProductID],[ProductName]" & _
  6.                                 " ,[ProductCategory],[Barcode],[ProductLevel],[ProductComment],[LocationID],[LocationName],[LocationComments]" & _
  7.                                 " ,[ExhibitionID],[ExhibitionName],[ExhibitionLevel],[ExhibitionPossition],[ExhibitionComment],[VariableID]" & _
  8.                                 " ,[VariableName],[VariableAtribute],[VariableValue],[VariableComments],[FactType],[ReUser])" & _
  9.                                 " VALUES(" & String.Format("{0:dd-MM-yyyy}", DateTime.Now.Date) & ",@CountryID,@ContryName,@StoreID,@NSO_StoreID,@StoreName " & _
  10.                                 " ,@StoreAddres ,@StoreStatud,@StoreComments,@StoreStarDateTime,@StoreEndDateTime,@StoreClosing" & _
  11.                                 " ,@PlannetAudit,@AuditInstructionID,@SyneryMode,@IMDB_ProductID,@NSO_ProductID,@ProductName" & _
  12.                                 " ,@ProductCategory,@Barcode,@ProductLevel,@ProductComment,@LocationID,@LocationName,@LocationComments" & _
  13.                                 " ,@ExhibitionID,@ExhibitionName,@ExhibitionLevel,@ExhibitionPossition,@ExhibitionComment,@VariableID" & _
  14.                                 " ,@VariableName,@VariableAtribute,@VariableValue,@VariableComments,@FactType,@ReUser)"
  15.                                 'Comm.Parameters.AddWithValue("@Fecha12", String.Format("{0:dd-MM-yyyy}", DateTime.Now.Date))
  16.                                Comm.Parameters.AddWithValue("@CountryID", f(0).ToString())
  17.                                 Comm.Parameters.AddWithValue("@ContryName", f(1).ToString())
  18.                                 Comm.Parameters.AddWithValue("@StoreID", f(2).ToString())
  19.                                 Comm.Parameters.AddWithValue("@NSO_StoreID", f(3).ToString())
  20.                                 Comm.Parameters.AddWithValue("@StoreName", f(4).ToString())
  21.                                 Comm.Parameters.AddWithValue("@StoreAddres", f(5).ToString())
  22.                                 Comm.Parameters.AddWithValue("@StoreStatud", f(6).ToString())
  23.                                 Comm.Parameters.AddWithValue("@StoreComments", f(7).ToString())
  24.                                 Comm.Parameters.AddWithValue("@StoreStarDateTime", f(8).ToString())
  25.                                 Comm.Parameters.AddWithValue("@StoreEndDateTime", f(9).ToString())
  26.                                 Comm.Parameters.AddWithValue("@StoreClosing", f(10).ToString())
  27.                                 Comm.Parameters.AddWithValue("@PlannetAudit", f(11).ToString())
  28.                                 Comm.Parameters.AddWithValue("@AuditInstructionID", f(12).ToString())
  29.                                 Comm.Parameters.AddWithValue("@SyneryMode", f(13).ToString())
  30.                                 Comm.Parameters.AddWithValue("@IMDB_ProductID", f(14).ToString())
  31.                                 Comm.Parameters.AddWithValue("@NSO_ProductID", f(15).ToString())
  32.                                 Comm.Parameters.AddWithValue("@ProductName", f(16).ToString())
  33.                                 Comm.Parameters.AddWithValue("@ProductCategory", f(17).ToString())
  34.                                 Comm.Parameters.AddWithValue("@Barcode", f(18).ToString())
  35.                                 Comm.Parameters.AddWithValue("@ProductLevel", f(19).ToString())
  36.                                 Comm.Parameters.AddWithValue("@ProductComment", f(20).ToString())
  37.                                 Comm.Parameters.AddWithValue("@LocationID", f(21).ToString())
  38.                                 Comm.Parameters.AddWithValue("@LocationName", f(22).ToString())
  39.                                 Comm.Parameters.AddWithValue("@LocationComments", f(23).ToString())
  40.                                 Comm.Parameters.AddWithValue("@ExhibitionID", f(24).ToString())
  41.                                 Comm.Parameters.AddWithValue("@ExhibitionName", f(26).ToString())
  42.                                 Comm.Parameters.AddWithValue("@ExhibitionLevel", f(26).ToString())
  43.                                 Comm.Parameters.AddWithValue("@ExhibitionPossition", f(27).ToString())
  44.                                 Comm.Parameters.AddWithValue("@ExhibitionComment", f(28).ToString())
  45.                                 Comm.Parameters.AddWithValue("@VariableID", f(29).ToString())
  46.                                 Comm.Parameters.AddWithValue("@VariableName", f(30).ToString())
  47.                                 Comm.Parameters.AddWithValue("@VariableAtribute", f(31).ToString())
  48.                                 Comm.Parameters.AddWithValue("@VariableValue", f(32).ToString())
  49.                                 Comm.Parameters.AddWithValue("@VariableComments", f(33).ToString())
  50.                                 Comm.Parameters.AddWithValue("@FactType", f(34).ToString())
  51.                                 Comm.Parameters.AddWithValue("@ReUser", f(35).ToString())
  52.                                 Comm.Connection = Cone
  53.                             next


inserta la primera fila luego me aparece un cuadro de texto que me dice que la variable ya esta declarda que debe ser unica por cada lote o procedimiento