hi,
i'm new in vb.net. i have a code that supposed to execute an exe file. then the exe file will produce a txt file. then, i want to read that txt file and put it in the sql database. but this error keep occur. please anybody, help me. thanks in advance.
here are the code :
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim extracProcess As New Process()
Process.Start("procc.exe")
Dim data As New SqlDataAdapter
Dim con As SqlConnection = New SqlConnection("...connection string...")
Using sw2 As StreamReader = New StreamReader("storedData.txt")
Dim temp As Integer = 0
For temp = 0 To All_codeDataGridView.Rows.Count - 1
If sw2.EndOfStream() = False Then
Dim sql1 As String
sql1 = "update temp set result = " & sw2.ReadLine() & " where feeder_id= " & All_codeDataGridView.Rows(temp).Cells("feeder_id_txt").Value
Using conn As New SqlConnection(con.ConnectionString)
Dim cmd3 As New SqlCommand(sql1, conn)
cmd3.Connection = conn
conn.Open()
cmd3.ExecuteNonQuery()
conn.Close()
End Using
End If
Next
sw2.Close()
End Using
End Sub
and the error :
i'm new in vb.net. i have a code that supposed to execute an exe file. then the exe file will produce a txt file. then, i want to read that txt file and put it in the sql database. but this error keep occur. please anybody, help me. thanks in advance.
here are the code :
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim extracProcess As New Process()
Process.Start("procc.exe")
Dim data As New SqlDataAdapter
Dim con As SqlConnection = New SqlConnection("...connection string...")
Using sw2 As StreamReader = New StreamReader("storedData.txt")
Dim temp As Integer = 0
For temp = 0 To All_codeDataGridView.Rows.Count - 1
If sw2.EndOfStream() = False Then
Dim sql1 As String
sql1 = "update temp set result = " & sw2.ReadLine() & " where feeder_id= " & All_codeDataGridView.Rows(temp).Cells("feeder_id_txt").Value
Using conn As New SqlConnection(con.ConnectionString)
Dim cmd3 As New SqlCommand(sql1, conn)
cmd3.Connection = conn
conn.Open()
cmd3.ExecuteNonQuery()
conn.Close()
End Using
End If
Next
sw2.Close()
End Using
End Sub
and the error :
Attachments
Last edited: