Hi all,
I need to import a text file data to Oracle using ADO.NET,
First I create a DataSet from Oracle table ,TEST_A,
Private Sub OraOLEDB()
Dim OraConn As OleDbConnection = New OleDbConnection("Provider= MSDAORA.1;" & _
"User ID = XXXX;" & _
"Password= XXXX;" & _
"Data Source=XXXX")
Try
OraConn.Open()
Dim OraDataAdpt As New OleDbDataAdapter("SELECT * FROM TEST_A", OraConn)
Dim OraDataSet As New DataSet("SA")
Dim OraDataTable As New DataTable("TEST_A")
OraDataAdpt.Fill(OraDataSet, "TEST_A")
Catch ex As Exception
MessageBox.Show(Err.Description)
'MessageBox.Show("Failed to connect to data source")
Finally
If OraConn.State = ConnectionState.Open Then
OraConn.Close()
End If
OraConn.Dispose()
End Try
End Sub
I wrote some code to split data in text file and save to DataSet:
Dim FileStream As StreamReader
Dim sLine As String = ""
Dim TextDelimiter As String = Chr(9) '{TAB}
Dim Splitout() As String
Dim I As Integer
FileStream = File.OpenText("c:\test.txt")
Do
sLine = FileStream.ReadLine()
If Not sLine Is Nothing Then
Splitout = Split(sLine, TextDelimiter)
For I = 0 To UBound(Splitout)
'Save To DataSet
Next I
End If
Loop Until sLine Is Nothing
FileStream.Close()
After done, I need to insert all data to Oracle table,but don't know how to do.
Can anybody help me with this ?
Or maybe you have better solution with the import feature is welcome.
Cheers,
Stanley