Sunday, June 7, 2015

Imports System.Data

Imports System.Data.SqlClient

Imports System.IO



 

Public Class Form1

Dim conn = New SqlConnection

Dim adptr = New SqlDataAdapter

Dim cmd = New SqlCommand

Dim i As Integer



 

Dim DT = New DataTable



 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Try

Dim objSRFile As StreamReader

Dim strInput, arrStrInput() As String

Dim intCurrPos As Integer

Dim strName As String

Dim address As String

Dim contents As String

Dim notice As String

strName = String.Empty

address = String.Empty

contents = String.Empty

notice = String.Empty

'Dim intSalary As Integer

'DB vars

Dim strSQL As String

Dim strConnString As String = "Data Source=.;Initial Catalog=Northwind;Integrated Security=True"

Dim Con As New SqlConnection(strConnString)

Dim objCmd As SqlCommand

Dim vText As String

Dim vstring(-1) As String

Dim p1 As String() = {vbTab} 'Note I am using a string array and the vbTab Constant

Dim vData As String = ""



Con.Open()

Using rvsr As New StreamReader("E:\Rastpro\logfile.txt")

While rvsr.Peek <> -1



vText = rvsr.ReadLine()

vstring = vText.Split(p1, StringSplitOptions.RemoveEmptyEntries) 'I am also using the option to remove empty entries a



strName = vstring(0)

notice = vstring(1)

address = vstring(2)

contents = vstring(3)

strSQL = "insert into TestingExport1(date,notice,address,contents) values('" & strName & "', '" & notice & "', '" & address & "', '" & contents & "')"

objCmd = New SqlCommand(strSQL, Con)



objCmd.ExecuteNonQuery()

End While

End Using





Catch ex As Exception

Trace.Write(ex.Message)

End Try

End Sub





End Class


Create Table Name TestingExport1
and All columns should be varchar1000