Click here to Skip to main content
11,795,568 members (77,927 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: XML database VB.NET convert , +
when I just execute this program error notification will be shown:

Sub insert()
      Dim ds As New DataSet
      Dim xmlFile As XmlReader
      Dim sql As String
      Dim id As String
      Dim company As String
      Dim datecom As Date
      Dim time As String
      Dim place As String
      Dim address As String
      Dim type As String
      Dim hidden As String
      xmlFile = XmlReader.Create("../../XML/datacoba.xml", New XmlReaderSettings())
      Dim i As Integer
      For i = 0 To ds.Tables(0).Rows.Count - 1
          id = ds.Tables(0).Rows(i).Item(0)
          '<on this line will be shown error "cannot find column 1" >
          company = ds.Tables(0).Rows(i).Item(1)
          datecom = (ds.Tables(0).Rows(i).Item(2))
          time = (ds.Tables(0).Rows(i).Item(3))
          place = ds.Tables(0).Rows(i).Item(4)
          address = ds.Tables(0).Rows(i).Item(5)
          type = ds.Tables(0).Rows(i).Item(6)
          hidden = ds.Tables(0).Rows(i).Item(7)
          sql = "insert into seminar_insert values(" & id & ",'" & company & "'," & datecom & "," & time & "," & place & "," & address & "," & type & "," & hidden & ")"
          'Command = New SqlCommand(sql, connection)
          cmd.CommandType = CommandType.Text
  End Sub
and this is xml files:
<?xml version="1.0" encoding="utf-8"?>
<!--XML Files datakonsumen-->
        <!--Start record-->
        <company>PT rubungjaya</company>
        <company>Pemkab malang</company>
        <place>Gedung graha cakra</place>
        <address>Jl melati, Malang</address>
        <company>PT alca</company>
        <id />
        <company />
        <date />
Posted 24-May-13 16:36pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You have an improper SQL statement, if you don't specify data for EVERY column, you must identify the columns you are inserting into.[^]

Otherwise how can the data driver know what columns you are trying to use?
Helmi Avicenna at 24-May-13 23:19pm
I mean before execute the insert query.
error message shown on this line: company = ds.Tables(0).Rows(i).Item(1)

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

  Print Answers RSS
0 Maciej Los 340
1 Sergey Alexandrovich Kryukov 316
2 OriginalGriff 285
3 Abhinav S 223
4 KrunalRohit 214
0 OriginalGriff 1,797
1 Maciej Los 1,415
2 KrunalRohit 1,240
3 CPallini 840
4 ppolymorphe 808

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100