Click here to Skip to main content
15,921,276 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dim connect As String
      connect = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & Application.StartupPath & "\segdata.accdb"
      Dim conn As New OleDbConnection(connect)

      Dim sr As System.IO.StreamReader
      Dim entirefile As String

      sr = File.OpenText(Application.StartupPath & "\SEG1.txt")
      entirefile = sr.ReadToEnd() ' Read the whole file

      Dim OriginalValue As String
      OriginalValue = vbTab
      Dim ReplaceValue As String
      ReplaceValue = ","
      entirefile = entirefile.Replace(OriginalValue, ReplaceValue)
      Dim sw As IO.StreamWriter = File.CreateText(Application.StartupPath & "\SEG1.txt")

      Dim query As String = "INSERT INTO  SEGDATA (School, Campus, AdminNo, ModuleCode, ModuleGrp) " & _
     "SELECT F1 as School, F2 as Campus, F3 as AdminNo, F4 as ModuleCode, F5 as ModuleGrp FROM [Text;DATABASE=" & System.IO.Path.GetDirectoryName(Me.OpenFileDialog1.FileName) & ";HDR=NO].[" & Me.OpenFileDialog1.SafeFileName & "]"
      Dim cmd As OleDbCommand = New OleDbCommand(query, conn)


i have these codes to actually replace the tabs delimiter to commas in my text file and insert them into access database. but im receiving this error: "No value given for one or more parameters" Anyone tell me whats wrong?
if i remove the part for the replacement of delimiters, and select a pure CSV file, it works fine.
[no name] 15-Jul-13 23:14pm    
u may store in Datagridview and insert from datagridview

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900