Well I tell you that I'm making a file listing in a datagridView for them I am using the tools of:
Sql server Visual Basic Window Form
If you show me, but when I click on it, it generates and opens several forms like the image. How could I make so that the fields are only shown in a form and sorted down? This is my code first when I give it generate from FORM 1:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim objReader As New StreamReader(OpenFileDialog.FileName) Dim sLine As String = "" Dim arrText As New ArrayList() Do sLine = objReader.ReadLine() If Not sLine Is Nothing Then arrText.Add(sLine) End If Loop Until sLine Is Nothing objReader.Close() Using Con As New SqlConnection(ConfigurationManager.ConnectionStrings("conexion").ConnectionString) Con.Open() For Each sLine In arrText Using command As New SqlCommand("RegistrarDatosTxt", Con) command.CommandType = CommandType.StoredProcedure command.Parameters.AddWithValue("@opt", 1) command.Parameters.Add("@numerocredito", SqlDbType.VarChar, 30).Value = sLine command.ExecuteNonQuery() MessageBox.Show("Se Generaron Correctamente los Numero de Creditos", "..::Aviso del Sistema::..") Dim frm As New Form2 frm.Show() End Using Next End Using End Sub
The second form that shows is this code:
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim oConn As SqlConnection oConn = New SqlConnection("Server=192.168.105.150\SQL2012;database=credito;uid=sa;pwd=DBServ@14;") If oConn.State = 1 Then oConn.Close() oConn.Open() Dim table As New DataTable Dim Adp As New SqlDataAdapter() Adp.SelectCommand = New SqlCommand() ' Creando una Instancia de SqlCommand Adp.SelectCommand.Connection = oConn 'Conexión Adp.SelectCommand.CommandText = "RegistrarDatosTxt" Adp.SelectCommand.CommandType = CommandType.StoredProcedure Adp.SelectCommand.Parameters.Add("@opt", SqlDbType.Int, 4) Adp.SelectCommand.Parameters("@opt").Value = 2 Adp.SelectCommand.Parameters.Add("@numerocredito", SqlDbType.VarChar, 30) Adp.SelectCommand.Parameters("@numerocredito").Value = "" Adp.Fill(table) DataGridView1.DataSource = table End Sub