Re: getting error on record duplication

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On 29 mei, 09:57, "Cor Ligthert[MVP]" <Notmyfirstn...@xxxxxxxxx>
wrote:
Hi Co,

Helping you is no problem, but you can make it more easy for us.

It is not needed for us to see your complete program. As it is the time for
that you will be asked for sure.

Give us the relevant parts, then helping you is much easier and more
effective

Something in general about programming, do all data names in English or do
them in Dutch, now it looks so amateuristic.

There is an advance for using Dutch names, but I find it awful reading so I
don't do that.

What is the reason you do it bottom up, that should be done when you are
deleting?

Cor

"Co" <vonclausow...@xxxxxxxxx> wrote in message

news:9b65bbb1-7b1e-423e-bdf1-fe3012b4dc45@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi All,

I have following code to duplicate records in a database table:
When I duplicate one record everything works but when I try to add
more records I get this error:

"Conversion from type dbnull to type string is not valid."
The code stops at the lien saying:
                   dr = ds.Tables(0).Rows(j)

Sub FileDuplicator(ByVal oldNode As Integer, ByVal newNode As Integer,
ByVal fileID() As String)

       Dim sql As String = "SELECT * FROM Bestanden WHERE Lokatie=" &
oldNode
       Dim strTable As String = "Bestanden"
       Dim da As New OleDb.OleDbDataAdapter(sql, conn)
       Dim cb As New OleDb.OleDbCommandBuilder(da)
       Dim ds As New DataSet
       Dim i As Integer
       Dim newRow As DataRow

       Try
           da.SelectCommand = New OleDb.OleDbCommand(sql, conn)
           da.Fill(ds, strTable)

           Dim dr As DataRow

           For i = 0 To fileID.Length - 1
               For j As Integer = ds.Tables(0).Rows.Count - 1 To 0
Step -1
                   dr = ds.Tables(0).Rows(j)
                   'For Each dr In ds.Tables(0).Rows
                   If CStr(dr.Item("Id")) = fileID(i) Then
                       'create this file in the folder
                       newRow = ds.Tables(strTable).NewRow()
                       newRow("filenaam") = dr.Item("filenaam")
                       newRow("status") = FixNull(dr.Item("status"))
                       newRow("lokatie") = newNode
                       newRow("extensie") = dr.Item("extensie")
                       newRow("grootte") = FixNull(dr.Item
("grootte"))
                       newRow("datum_gemaakt") = FixNull(dr.Item
("datum_gemaakt"))
                       newRow("datum_gewijzigd") = FixNull(dr.Item
("datum_gewijzigd"))
                       newRow("expires") = FixNull(dr.Item
("expires"))
                       newRow("hddlokatie") = FixNull(dr.Item
("hddlokatie"))
                       newRow("samenvatting") = dr.Item
("samenvatting")
                       newRow("kenmerk") = FixNull(dr.Item
("kenmerk"))
                       newRow("auteur") = FixNull(dr.Item("auteur"))
                       newRow("soort") = FixNull(dr.Item("soort"))
                       newRow("inuit") = FixNull(dr.Item("inuit"))
                       ds.Tables(strTable).Rows..Add(newRow)
                   End If
               Next
           Next

               'sent the updated dataSet to the database
               da.Update(ds, strTable)

       Catch oException As OleDbException
           MessageBox.Show(oException.Message)

       Catch oException As Exception
           MessageBox.Show(oException.Message)

       End Try
       conn.Close()

   End Sub

Any thoughts?

Regards
Marco

You are right I should do them in English.
Is there a difference in going bottom up?

Marco
.



Relevant Pages

  • Change Language of all Windows XP-menus and mediaplayer and so on
    ... programnames and programcontents from English ... to Dutch on a new computer? ... Thanks for helping me out! ...
    (microsoft.public.windowsxp.basics)
  • Re: No Matter How Many Times Markie Chages The Subject, Hell Still Be A Liar
    ... Care to take some of YOUR postings and MY postings to an English ... >> USE CAPITALIZATION! ... It's not about helping me, ... Markie to Englsih translation: "He's got me by throat and I can't ...
    (rec.radio.amateur.policy)
  • Re: Language Problem Fix Here
    ... >>2) Download mp10setup.exe from the link below ... >>6) It *should* now be in English ... Replies are to help benefit others in helping ... >>you and reproducing issues, not necessarily for me ...
    (microsoft.public.windowsmedia.player)
  • Re: Media player 10 onto XP
    ... Replies are to help benefit others in helping ... > configured to Greek instead of English. ... > Microsoft are unwilling to help further without incurring ...
    (microsoft.public.windowsmedia.player)
  • Re: Chaos on the Llangollen (again)
    ... well the BW yard at Ellesmere where I've just spent ... three days helping a mate black his bottom, is that it isn't as serious as ...
    (uk.rec.waterways)