The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: xPLMediaNet - Need some .net oledb help please


  • Subject: Re: xPLMediaNet - Need some .net oledb help please
  • From: Tom Van den Panhuyzen <tomvdp@xxxxxxxxx>
  • Date: Mon, 25 Jul 2005 21:40:00 +0200
  • References: <42e51539.59cdfa86.36ab.ffff8e24SMTPIN_ADDED@mx.gmail.com>

Hi Tony,
DA.Update() will call the UpdateCommand for each modified row. In theory
DA.Update() should raise an error if you didn't explicitly set a
DA.UpdateCommand...
You will have to add the primary key in the select statement if you want
the results to be update-able. If the key is "MusicId":
rstSELECT.CommandText = "SELECT *MusicId*, Path FROM Music WHERE Path
Like
?"
Then you can set the DA.UpdateCommand:

DA.UpdateCommand = New OleDbCommand("update Music set Path=@Path where
MusicId=@MusicId", dbs)
DA.UpdateCommand.Parameters.Add("path", OleDbType.VarChar, 255)
Dim P as OleDbParameter =
DA.UpdateCommand.Parameters.Add("MusicId",
OleDbType.Integer)
P.SourceColumn = "MusicId"
P.SourceVersion = DataRowVersion.Original

The rest of your code needs no modification.
More info here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconupdatingdatabasewithdataadapterdataset.asp
Cheers,
Tom
On 7/25/05, Tony Tofts <tony@xxxxxxx> wrote:
> Hi all,
>
> Was wondering if anyone can tell me how to fix the code below please?
>
> The idea is when a folder is renamed the code updates all appropriate
> records in the database. But as the folder can have subfolders I can't
> simply update the 'Path' field as I need to change part fields too
(e.g.
if
> c:\MP3\Test is renamed to c:\MP3\Test2 then I need to change
c:\MP3\Test\
to
> c:\MP3\Test2\ and c:\MP3\Test\An Artist\ to c:\MP3\Test2\An Artist
etc)
>
> The code runs thru ok, and if I look at the value of dt.row(x).item(0)
they
> all change to the modified value, but I can't work out how to write it
back
> to the database??? The DA.Update doesn't error, but does nothing.
>
> Any thoughts please?
>
> Many thanks
> Tony
>
> Dim rstSELECT As New OleDbCommand
> rstSELECT.Connection = dbs
> rstSELECT.CommandText = "SELECT Path FROM Music WHERE Path Like
?"
> rstSELECT.Parameters.Add("path", OleDbType.VarChar, 255)
> rstSELECT.Parameters("path").Value = OldFullPath &
"\%"
> Dim DA As OleDbDataAdapter = New OleDbDataAdapter(rstSELECT)
> Dim DT As New DataTable
> DA.Fill(DT)
> If DT.Rows.Count = 0 Then
> rstSELECT.Dispose()
> Exit Sub ' nothing found
> End If
> For x As Long = 0 To DT.Rows.Count - 1
> DT.Rows(x).Item(0) = FullPath & Mid(DT.Rows(x).Item(0),
Len(OldFullPath) +
> 1)
> Next
> DT.AcceptChanges() <-- has no effect
> DA.Update(DT) <-- has no effect
> rstSELECT.Dispose()
>
>
>
> xPL Links: http://www.xplproject.org.uk http://www.xplhal.com
http://www.xpl.myby.co.uk
> To Post a Message: ukha_xpl@xxxxxxx
> To Subscribe: ukha_xpl-subscribe@xxxxxxx
> To Unsubscribe: ukha_xpl-unsubscribe@xxxxxxx
>
>
>
> ________________________________
YAHOO! GROUPS LINKS
>
>
> Visit your group "ukha_xpl" on the web.
>
> To unsubscribe from this group, send an email to:
> ukha_xpl-unsubscribe@xxxxxxx
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> To unsubscribe from this group, send an email to:
> ukha_xpl-unsubscribe@xxxxxxx
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
> ________________________________


[Non-text portions of this message have been removed]



xPL Links: http://www.xplproject.org.uk http://www.xplhal.com http://www.xpl.myby.co.uk
To Post a Message: ukha_xpl@xxxxxxx
To Subscribe:  ukha_xpl-subscribe@xxxxxxx
To Unsubscribe:  ukha_xpl-unsubscribe@xxxxxxx

xPL Main Index | xPL Thread Index | xPL Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.