Well I told you that I'm doing extracting the data from a txt file and storing it in a table for them I'm using the tools of:
- Sql server
- Visual Basic Window Form
Inside my table you only have these fields:
- Id int identity (1,1) not null
- numbercredit [nvarchar] (50) NOT NULL
inside my code this:
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() Using command As New SqlCommand("RegistrarDatosTxt", Con) command.CommandType = CommandType.StoredProcedure command.Parameters.AddWithValue("@opt", 1) For Each sLine In arrText command.Parameters.Add("@numerocredito", SqlDbType.VarChar, 30).Value = sLine command.ExecuteNonQuery() MessageBox.Show("Se Generaron Correctamente los Numero de Creditos", "..::Aviso del Sistema::..") Next Dim frm As New Form2 frm.Show() End Using End Using
I commented that if you save information from a txt file but only if you have a line, but if you have more than two lines like this:
does not register and tells me the error that has more established fields. My question is how could I save several lines of txt on my table?