Resize a set of fields in a set of tables by means of a .NET loop

1

I have two vectors with String data

Public tablas() As String = {"LinFraVen", "LinAlbVen", "LinPedCli", "LinPres", "LinFraCom", "LinAlbCom", "LinPedPro", "LinInven", "LinTarifa", "NecesidadProductos", "LinCuotas", "LinActob", "LinOrdCom", "LinOrdSeg", "DenominacionesAmpliadas", "Etiquetas"}
Public campos() As String = {"descripción", "descripción", "descripción", "descripción", "descripción", "descripción", "descripción", "descripción", "descripción", "descripción", "denominacion", "descripción", "descripción", "DenominacionAmpliada", "denominacion"}

I have to resize the fields to (100 TEXT) For example:

LinFraVen campo descripcion 
LinAlbVen campo descripcion 
DenominacionesAmpliadas campo DenominacionAmpliada

The code to resize would be this

cmdOledb = New OleDbCommand("ALTER TABLE productos ALTER COLUMN Denominacion TEXT(50)", conexion)

As I could go through a loop and go resizing the fields, in the following way. Position 1 within tables your field is position 1 within fields, and so on. Thank you very much

    
asked by Sam.Gold 20.03.2017 в 13:31
source

2 answers

1

You just have to compare the indexes to match the fixes and apply a break instruction if to do it.

Something like this:

List<string> v1 = new List<string> { "1", "2", "3", "4", "5" };
List<string> v2 = new List<string> { "uno", "dos", "tres", "cuatro", "cinco" };

            for(int i = 0; i < v1.Count; i++)
            {
                for(int x = 0; x < v2.Count; x++)
                {
                    if(x == i)
                    {
                        Console.WriteLine(v1[i] + "/" + v2[x]);
                        break;
                    }
                }
            }
            Console.ReadLine();
    
answered by 20.03.2017 / 14:45
source
0

You can use ArrayList or better yet the StringCollection class. Then you can resize your collection:

Dim myCol As New StringCollection()
//Agrega los elementos al final de la colección
myCol.Add("columna1")
myCol.Add("columnaN")

//Agrega los elementos en el índice que necesites
//myCol.Insert(indice, texto)
myCol.Insert(1, "columna2")
    
answered by 20.03.2017 в 13:42